pub struct DirectoryGraphBuilder {
insertion_order: DirectoryOrder,
graph: DiGraph<Directory, ()>,
digest_to_node_idx_size: HashMap<B3Digest, (NodeIndex, u64)>,
rtl_edges_todo: HashMap<B3Digest, (u64, Vec<NodeIndex>)>,
exp_root_digest: Option<B3Digest>,
}Expand description
This allows constructing a DirectoryGraph. After deciding on the insertion order (Self::new_leaves_to_root or Self::new_root_to_leaves with the expected root digest passed), different Directory can be passed to Self::try_insert. A Self::build consumes the builder, returning a validated DirectoryGraph, or an error. The resulting DirectoryGraph can be used to drain the graph in Leaves-To-Root or Root-To-Leaves order.
It does do the same checks as RootToLeavesValidator and LeavesToRootValidator
(insertion order, completeness, connectivity, correct sizes referenced).
Fields§
§insertion_order: DirectoryOrderThe order of Directory elements Self::try_insert is called with.
graph: DiGraph<Directory, ()>A directed graph, using Directory as node weight. Edges point from parents to children.
digest_to_node_idx_size: HashMap<B3Digest, (NodeIndex, u64)>A lookup table from directory digest to node index and size. The size is stored to avoid having to calculate it multiple times.
rtl_edges_todo: HashMap<B3Digest, (u64, Vec<NodeIndex>)>A map from digest to size and all node indexes that are pointing to it. Used in the RTL case for all unfinished edges.
exp_root_digest: Option<B3Digest>Holds the expected root digest. Populated in the RTL case only.
Implementations§
Source§impl DirectoryGraphBuilder
impl DirectoryGraphBuilder
Sourcepub fn new_leaves_to_root() -> Self
pub fn new_leaves_to_root() -> Self
Constructs a new DirectoryGraphBuilder accepting directories in Leaves-To-Root order.
Sourcepub fn new_root_to_leaves(root_digest: B3Digest) -> Self
pub fn new_root_to_leaves(root_digest: B3Digest) -> Self
Constructs a new DirectoryGraphBuilder accepting directories in Root-To-Leaves order. The expected root Directory needs to be passed as an argument, and is validated to match the one inserted on the first call to Self::try_insert.
pub fn try_insert(&mut self, directory: Directory) -> Result<(), OrderingError>
pub fn build(self) -> Result<DirectoryGraph, OrderingError>
Auto Trait Implementations§
impl Freeze for DirectoryGraphBuilder
impl RefUnwindSafe for DirectoryGraphBuilder
impl Send for DirectoryGraphBuilder
impl Sync for DirectoryGraphBuilder
impl Unpin for DirectoryGraphBuilder
impl UnwindSafe for DirectoryGraphBuilder
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request