Trait constriction::Pos
source · pub trait Pos: PosSeek {
// Required method
fn pos(&self) -> Self::Position;
}
Expand description
A trait for entropy coders that keep track of their current position within the compressed data.
This is the counterpart of Seek
. Call Pos::pos
to record
“snapshots” of an entropy coder, and then call Seek::seek
at a later time
to jump back to these snapshots. See examples in the documentations of Seek
and Seek::seek
.
Required Methods§
sourcefn pos(&self) -> Self::Position
fn pos(&self) -> Self::Position
Returns the position in the compressed data, in units of Word
s.
It is up to the entropy coder to define what constitutes the beginning and end
positions within the compressed data (for example, a AnsCoder
begins encoding
at position zero but it begins decoding at position ans.buf().len()
).
Implementations on Foreign Types§
source§impl<Array> Pos for SmallVec<Array>where
Array: Array,
impl<Array> Pos for SmallVec<Array>where
Array: Array,
source§fn pos(&self) -> usize
fn pos(&self) -> usize
Returns the length of the SmallVec
since that’s the current read and write
position (SmallVec
s, like Vec
s, have Stack
semantics).
If you have a Vec
or SmallVec
with name v
and your intention is to read to or
write from it at arbitrary positions rather than just at the end then you probably
want to wrap either v
or the slice &v[..]
in a Cursor
.
source§impl<Word> Pos for Vec<Word>
impl<Word> Pos for Vec<Word>
source§fn pos(&self) -> usize
fn pos(&self) -> usize
Returns the length of the vector since that’s the current read and write position
(vectors have Stack
semantics).
If you have a Vec
with name v
and your intention is to read to or write from it
at arbitrary positions rather than just at the end then you probably want to wrap
either v
or the slice &v[..]
in a Cursor
.