Struct PostOrderMemOutboard

Source
pub struct PostOrderMemOutboard<T = Vec<u8>> {
    pub root: Hash,
    pub tree: BaoTree,
    pub data: T,
}
Expand description

A post order outboard that is optimized for memory storage.

The PostOrderOutboard will work just fine using e.g. a Vec<u8> as storage. However, it will not work for types such as bytes::Bytes or bytes::BytesMut that do not implement the io traits.

The traits are implemented for fixed size slices or mutable slices, so unlike the PostOrderOutboard, you must make sure that the data is already the right size.

Fields§

§root: Hash

root hash

§tree: BaoTree

tree defining the data

§data: T

hashes without length suffix

Implementations§

Source§

impl PostOrderMemOutboard

Source

pub fn create(data: impl AsRef<[u8]>, block_size: BlockSize) -> Self

Create a new outboard from data and a block_size.

This will hash the data and create an outboard.

It is just a shortcut that calls crate::io::sync::outboard_post_order.

Source

pub fn into_inner_with_suffix(self) -> Vec<u8>

returns the outboard data, with the length suffix.

Source§

impl<T> PostOrderMemOutboard<T>

Source

pub fn map_data<F, U>(self, f: F) -> PostOrderMemOutboard<U>
where F: FnOnce(T) -> U, U: AsRef<[u8]>,

Map the outboard data to a new type.

Source

pub fn flip(&self) -> PreOrderMemOutboard
where T: AsRef<[u8]>,

Flip the outboard to pre order.

Trait Implementations§

Source§

impl<T: Clone> Clone for PostOrderMemOutboard<T>

Source§

fn clone(&self) -> PostOrderMemOutboard<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for PostOrderMemOutboard<T>

Source§

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

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

impl<T: Default> Default for PostOrderMemOutboard<T>

Source§

fn default() -> Self

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

impl<T: AsRef<[u8]>> Outboard for PostOrderMemOutboard<T>

Source§

fn root(&self) -> Hash

The root hash
Source§

fn tree(&self) -> BaoTree

The tree. This contains the information about the size of the file and the block size.
Source§

fn load(&self, node: TreeNode) -> Result<Option<(Hash, Hash)>>

load the hash pair for a node
Source§

impl<T: AsRef<[u8]>> Outboard for PostOrderMemOutboard<T>

Source§

fn root(&self) -> Hash

The root hash
Source§

fn tree(&self) -> BaoTree

The tree. This contains the information about the size of the file and the block size.
Source§

async fn load(&mut self, node: TreeNode) -> Result<Option<(Hash, Hash)>>

load the hash pair for a node Read more
Source§

impl<T: AsMut<[u8]>> OutboardMut for PostOrderMemOutboard<T>

Source§

fn save(&mut self, node: TreeNode, pair: &(Hash, Hash)) -> Result<()>

Save a hash pair for a node
Source§

fn sync(&mut self) -> Result<()>

Sync the outboard.
Source§

impl<T: AsMut<[u8]>> OutboardMut for PostOrderMemOutboard<T>

Source§

async fn save(&mut self, node: TreeNode, pair: &(Hash, Hash)) -> Result<()>

Save a hash pair for a node
Source§

async fn sync(&mut self) -> Result<()>

sync to disk
Source§

impl<T: PartialEq> PartialEq for PostOrderMemOutboard<T>

Source§

fn eq(&self, other: &PostOrderMemOutboard<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq> Eq for PostOrderMemOutboard<T>

Source§

impl<T> StructuralPartialEq for PostOrderMemOutboard<T>

Auto Trait Implementations§

§

impl<T> Freeze for PostOrderMemOutboard<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for PostOrderMemOutboard<T>
where T: RefUnwindSafe,

§

impl<T> Send for PostOrderMemOutboard<T>
where T: Send,

§

impl<T> Sync for PostOrderMemOutboard<T>
where T: Sync,

§

impl<T> Unpin for PostOrderMemOutboard<T>
where T: Unpin,

§

impl<T> UnwindSafe for PostOrderMemOutboard<T>
where T: UnwindSafe,

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.