Skip to main content

Replay

Struct Replay 

Source
pub struct Replay<'a> { /* private fields */ }
Expand description

Encode an integer chunk the way an earlier one came out, and search only where it stops fitting.

Settled holds one kind per level, which is too coarse for a cascade that branches: an RLE wants its run values packed and its run lengths constant, and a shape of one kind per level cannot say both. This holds every level’s kind in the order the encoder asks for them, which is what integer::shape reads back out of an encoded chunk, and hands them back one per question.

The first question whose answer is not among the kinds offered ends the replay, and from there on every question goes to fallback. A chunk only offers kinds that apply to it, so a shape that stops fitting costs a search and never a chunk that will not decode. The order of the questions is the order of the kinds only while every answer is a single kind, which is why the replay does not pick back up after a search.

A shape that still fits can still be the wrong one. Bit packing applies to everything, so a shape settled on a stretch of noise replays happily over a column that has since become one value with exceptions, at forty times the size. What does change when the column does is the set of kinds the top level offers, so a replay can be told the set its shape was searched under with Replay::expecting, and searches from the top when the chunk offers anything else. The set is worked out for the chunk whatever the chooser, so the check costs nothing.

One of these is for one chunk. The position is kept in atomics because a chooser is shared between threads by contract, not because a chunk’s encode is ever split between them.

Implementations§

Source§

impl<'a> Replay<'a>

Source

pub fn new(kinds: &'a [Kind], fallback: &'a dyn Chooser) -> Self

A replay of kinds, with fallback answering once they stop fitting.

Source

pub fn expecting(self, offered: &[Kind]) -> Self

The same replay, going ahead only on a chunk whose top level offers exactly offered.

Source

pub fn first_offered(&self) -> Vec<Kind>

What the top level of the chunk offered, in tag order, or nothing before it was asked.

Source

pub fn held(&self) -> bool

Whether every question was answered from the shape, which is whether the chunk came out the shape it was given.

Trait Implementations§

Source§

impl Chooser for Replay<'_>

Source§

fn name(&self) -> &'static str

The name that goes in a report.
Source§

fn narrow_strings( &self, values: &[&[u8]], offered: &[Kind], depth: u8, ) -> Vec<Kind>

Which of offered to encode in full, for a chunk of strings at depth. Read more
Source§

fn narrow_integers( &self, values: &[i64], offered: &[Kind], depth: u8, ) -> Vec<Kind>

Which of offered to encode in full, for a chunk of integers at depth.
Source§

fn considers_integer(&self, kind: Kind, depth: u8) -> bool

Whether kind can ever be in what Chooser::narrow_integers returns at depth. Read more
Source§

impl<'a> Debug for Replay<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for Replay<'a>

§

impl<'a> !RefUnwindSafe for Replay<'a>

§

impl<'a> !UnwindSafe for Replay<'a>

§

impl<'a> Send for Replay<'a>

§

impl<'a> Sync for Replay<'a>

§

impl<'a> Unpin for Replay<'a>

§

impl<'a> UnsafeUnpin for Replay<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.