Trait StorageBackend

Source
pub trait StorageBackend {
    // Required methods
    fn store(&mut self, fl: u16, fh: u16, nms: u16);
    fn stream_bits(&mut self) -> usize;
    fn checkpoint(&mut self) -> WriterCheckpoint;
    fn rollback(&mut self, _: &WriterCheckpoint);
}
Expand description

StorageBackend is an internal trait used to tie a specific Writer implementation’s storage to the generic Writer. It would be private, but Rust is deprecating ‘private trait in a public interface’ support.

Required Methods§

Source

fn store(&mut self, fl: u16, fh: u16, nms: u16)

Store partially-computed range code into given storage backend

Source

fn stream_bits(&mut self) -> usize

Return bit-length of encoded stream to date

Source

fn checkpoint(&mut self) -> WriterCheckpoint

Backend implementation of checkpoint to pass through Writer interface

Source

fn rollback(&mut self, _: &WriterCheckpoint)

Backend implementation of rollback to pass through Writer interface

Implementors§

Source§

impl StorageBackend for WriterBase<WriterCounter>

The Counter stores nothing we write to it, it merely counts the bit usage like in an Encoder for cost analysis.

Source§

impl StorageBackend for WriterBase<WriterEncoder>

An Encoder produces an actual range-coded bitstream from passed in tokens. It does not retain any information about the coded tokens, only the resulting bitstream, and so it cannot be replayed (only checkpointed and rolled back).

Source§

impl StorageBackend for WriterBase<WriterRecorder>

The Recorder does not produce a range-coded bitstream, but it still tracks the range coding progress like in an Encoder, as it neds to be able to report bit costs for RDO decisions. It stores a pair of mostly-computed range coding values per token recorded.