Module: Zstd::Aux

Defined in:
lib/extzstd.rb

Constant Summary collapse

EMPTY_BUFFER =
"".force_encoding(Encoding::BINARY).freeze

Class Method Summary collapse

Class Method Details

.change_binary(str) ⇒ Object



284
285
286
287
288
289
290
# File 'lib/extzstd.rb', line 284

def self.change_binary(str)
  e = str.encoding
  str.force_encoding(Encoding::BINARY)
  yield
ensure
  str.force_encoding e rescue nil if e
end

.io_read(io, size, buf) ⇒ Object

Raises:



278
279
280
281
282
# File 'lib/extzstd.rb', line 278

def self.io_read(io, size, buf)
  raise Error, "encounted EOF (read error)" unless io.read(size, buf)
  raise Error, "read size too small (read error)" unless buf.bytesize == size
  buf
end