Skip to main content

LastCv

Struct LastCv 

Source
pub struct LastCv { /* private fields */ }
Expand description

The chaining value of a message’s last subtree, with its place and length: the right child at some level of the tree’s right edge. It may be shorter than its left sibling, and is never a left child: no call takes one on the left, so a tree with a short subtree inside it does not compile.

ⓘ
use blake3_servil_core::{Mode, throughput::TreeHasher};
let tree = TreeHasher::new(Mode::Plain);
let end = tree.last_cv(1, &[7u8; 100]);
let next = tree.subtree_cv(0, 2, &[7u8; 1024]);
let _ = tree.parent_cv(&end, &next); // a short subtree on the left

A whole subtree that ends the message becomes one by LastCv::from: the program says that the message ends there.

Equality and Debug are as Cv’s.

§Trait implementations

  • Clone reproduces the value, starting chunk and length.
  • Copy copies those coordinates along with the chaining bytes.
  • Debug shows the starting chunk and length without exposing chaining bytes.
  • Eq identifies values with equal coordinates and bytes.
  • From (of a Cv) keeps a whole subtree’s bytes and records its first chunk and full length, on the caller’s word that the message ends there; it panics on a Cv that was never set.
  • PartialEq compares both coordinates and compares the chaining bytes in constant time.

Implementations§

Source§

impl LastCv

Source

pub const fn at(first_chunk: u64, len: u64, bytes: [u8; 32]) -> Self

A chaining value a program stored or received, for the last subtree: the message’s last len bytes, which begin at its chunk first_chunk.

Requires what TreeHasher::last_cv does of the place and the length.

Source

pub const fn as_bytes(&self) -> &[u8; 32]

The chaining value’s bytes.

Source

pub const fn first_chunk(&self) -> u64

The message’s chunk the subtree begins at.

Source

pub const fn len(&self) -> u64

The subtree’s bytes: one or more.

Trait Implementations§

Source§

impl Clone for LastCv

Source§

fn clone(&self) -> LastCv

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 LastCv

Source§

impl Debug for LastCv

Source§

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

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

impl Eq for LastCv

Source§

impl From<Cv> for LastCv

A whole subtree that ends the message: the program says so.

Source§

fn from(cv: Cv) -> LastCv

Converts to this type from the input type.
Source§

impl PartialEq for LastCv

Source§

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

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

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

Inequality operator !=. Read more

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.