Skip to main content

EchoFrame

Struct EchoFrame 

Source
pub struct EchoFrame {
    pub start: u32,
    pub end: u32,
    pub keyed: bool,
    pub count: u32,
    pub back_lag: Option<NonZeroU32>,
    pub fwd_lag: Option<NonZeroU32>,
    pub period: f32,
    pub nth: u32,
}
Expand description

One token’s echo reading.

Fields§

§start: u32

Byte offset where the token begins, at the width Token stores it.

§end: u32

Byte offset just past the token, at the same width.

§keyed: bool

Whether the token participates in the recurrence field (word / number / quoted / typed-literal kinds at or above the length floor). Unkeyed tokens (whitespace, punctuation, brackets) carry a zero frame.

§count: u32

Occurrences of this token’s key in the document (1 = unique).

§back_lag: Option<NonZeroU32>

Byte distance back to the previous occurrence of the key, or None when this is the first (a novel token).

Non-zero because two occurrences of one key begin at different bytes, which is the niche that keeps the Option free: a plain Option<u32> is eight bytes where this is four, over one frame a token.

§fwd_lag: Option<NonZeroU32>

Byte distance forward to the next occurrence, or None at the last, non-zero for the same reason as EchoFrame::back_lag.

§period: f32

The key’s recurrence period in bytes when its lags are regular, and zero where it has none.

Zero rather than None, which saves the four bytes an Option<f32> spends on a discriminant over one frame a token. A period is only ever set from a mean lag the writer requires to be above zero, so zero was never a reading this could carry and reads as the absence it is.

Zero rather than a NaN, which would be the other way to mark it and is wrong twice here: Default gives an unkeyed token a zero frame and f32::default() is zero, not NaN, so absence would have two spellings; and NaN is unequal to itself, so the derived PartialEq would report two frames with no period as different.

§nth: u32

This occurrence’s place among the key’s, counting from one; zero for an unkeyed token.

Implementations§

Source§

impl EchoFrame

Source

pub fn novel(&self) -> bool

The first appearance of a keyed token: no prior occurrence.

Source

pub fn echoed(&self) -> bool

A keyed token whose key occurs more than once in the document.

Source

pub fn strength(&self) -> f32

The recurrence mass: occurrences beyond this one (0 = unique).

Trait Implementations§

Source§

impl Clone for EchoFrame

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for EchoFrame

Source§

impl Debug for EchoFrame

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for EchoFrame

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for EchoFrame

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for EchoFrame

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.