class BinData::IO::Transform

::transform_changes_stream_length! in your subclass.
data stream (e.g. compression), then call
IMPORTANT! If your transform changes the size of the underlying
and #after_write_transform are available as well.
Additionally the hook, #before_transform, #after_read_transform
Override the public methods #read and #write at a minimum.
To create a new transform layer, subclass Transform.
Multiple transforms can be chained together.
e.g. encoding, compression, buffered.
An IO stream may be transformed before processing.

def after_read_transform; end

Called after the final read operation.

Flushes the input stream.
def after_read_transform; end

def after_write_transform; end

Called after the final write operation.

Flushes the output stream.
def after_write_transform; end

def before_transform; end

Called before any IO operations.

Initialises this transform.
def before_transform; end

def chain_num_bytes_remaining

def chain_num_bytes_remaining
  @chain_io.num_bytes_remaining
end

def chain_offset

def chain_offset
  @chain_io.offset
end

def chain_read(n)

def chain_read(n)
  @chain_io.read(n)
end

def chain_seek_abs(n)

def chain_seek_abs(n)
  @chain_io.seek_abs(n)
end

def chain_seekable?

def chain_seekable?
  @chain_io.seekable?
end

def chain_skip(n)

def chain_skip(n)
  @chain_io.skip(n)
end

def chain_write(data)

def chain_write(data)
  @chain_io.write(data)
end

def create_empty_binary_string

def create_empty_binary_string
  String.new.force_encoding(Encoding::BINARY)
end

def initialize

def initialize
  @chain_io = nil
end

def num_bytes_remaining

How many bytes are available for reading?
def num_bytes_remaining
  chain_num_bytes_remaining
end

def offset

The current offset within the stream.
def offset
  chain_offset
end

def prepend_to_chain(chain)

Returns self (the new head of chain).

Prepends this transform to the given +chain+.
def prepend_to_chain(chain)
  @chain_io = chain
  before_transform
  self
end

def read(n)

Reads +n+ bytes from the stream.
def read(n)
  chain_read(n)
end

def seek_abs(n)

Seeks to the given absolute position.
def seek_abs(n)
  chain_seek_abs(n)
end

def seekable?

Is the IO seekable?
def seekable?
  @chain_io.seekable?
end

def skip(n)

Skips forward +n+ bytes in the input stream.
def skip(n)
  chain_skip(n)
end

def transform_changes_stream_length!

underlying data. e.g. performs compression or error correction
Indicates that this transform changes the length of the
def transform_changes_stream_length!
  prepend(UnSeekableIO)
end

def write(data)

Writes +data+ to the stream.
def write(data)
  chain_write(data)
end