pub struct MatchModel { /* private fields */ }Expand description
Match model: finds longest match in history, predicts from continuation.
Implementations§
Source§impl MatchModel
impl MatchModel
pub fn new() -> Self
Sourcepub fn with_sizes(buf_size: usize, hash_size: usize) -> Self
pub fn with_sizes(buf_size: usize, hash_size: usize) -> Self
Create a match model with custom ring buffer and hash table sizes. Both sizes must be powers of 2.
Sourcepub fn predict(&mut self, _c0: u32, bpos: u8, c1: u8, c2: u8, c3: u8) -> u32
pub fn predict(&mut self, _c0: u32, bpos: u8, c1: u8, c2: u8, c3: u8) -> u32
Predict probability of bit=1 based on match continuation. Returns 12-bit probability in [1, 4095].
c0: partial byte being decoded (1-255).
bpos: bit position (0-7).
c1: last completed byte.
c2: second-to-last byte.
c3: third-to-last byte.
Sourcepub fn update(&mut self, bit: u8, bpos: u8, c0: u32, c1: u8, c2: u8)
pub fn update(&mut self, bit: u8, bpos: u8, c0: u32, c1: u8, c2: u8)
Update match model after observing bit.
bit: observed bit.
bpos: bit position (0-7).
c0: partial byte (after this bit).
c1: last completed byte (if bpos==7, this byte just completed).
Sourcepub fn match_length_quantized(&self) -> u8
pub fn match_length_quantized(&self) -> u8
Return the quantized match length for mixer context. 0=no match, 1=short, 2=medium, 3=long.
Sourcepub fn last_prediction(&self) -> u32
pub fn last_prediction(&self) -> u32
Return the last predicted probability (for APM context).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MatchModel
impl RefUnwindSafe for MatchModel
impl Send for MatchModel
impl Sync for MatchModel
impl Unpin for MatchModel
impl UnsafeUnpin for MatchModel
impl UnwindSafe for MatchModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more