pub struct NodeBuilder<T, N = Node<T>, S = DefaultNodeSerializer>where
T: Clone,
S: NodeSerializer<N, T>,{ /* private fields */ }Expand description
Create a balances merkle tree of Node blocks.
Note: This implementation requires the data to fit into memory.
Implementations§
Source§impl<T, N, S> NodeBuilder<T, N, S>
impl<T, N, S> NodeBuilder<T, N, S>
pub fn new(max_block_size: usize, max_children: usize, serializer: S) -> Self
pub fn with_items_size_max(self, items_size_max: usize) -> Self
pub fn push(&mut self, item: T) -> Result<(), NodeBuilderError>
pub fn extend( &mut self, items: impl IntoIterator<Item = T>, ) -> Result<(), NodeBuilderError>
Sourcepub fn take_blocks(&mut self) -> impl Iterator<Item = Block>
pub fn take_blocks(&mut self) -> impl Iterator<Item = Block>
Take blocks from builder that already has been created.
Sourcepub fn into_blocks(
self,
) -> Result<(OptionLink<N>, Vec<Block>), NodeBuilderError>
pub fn into_blocks( self, ) -> Result<(OptionLink<N>, Vec<Block>), NodeBuilderError>
Convert builder into blocks.
All blocks that are not yet taken using NodeBuilder::take_blocks are returned.
Sourcepub fn into_node(self) -> Result<(N, Vec<Block>), NodeBuilderError>
pub fn into_node(self) -> Result<(N, Vec<Block>), NodeBuilderError>
Convert builder into a node and blocks if needed.
All blocks that are not yet taken using NodeBuilder::take_blocks are returned.
The root node is returned directly and not put into a block.
Trait Implementations§
Auto Trait Implementations§
impl<T, N, S> Freeze for NodeBuilder<T, N, S>where
S: Freeze,
impl<T, N, S> RefUnwindSafe for NodeBuilder<T, N, S>
impl<T, N, S> Send for NodeBuilder<T, N, S>
impl<T, N, S> Sync for NodeBuilder<T, N, S>
impl<T, N, S> Unpin for NodeBuilder<T, N, S>
impl<T, N, S> UnsafeUnpin for NodeBuilder<T, N, S>where
S: UnsafeUnpin,
impl<T, N, S> UnwindSafe for NodeBuilder<T, N, S>
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