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>)>,
first_idx: Option<NodeIndex>,
}Expand description
This allows constructing a DirectoryGraph. After deciding on the insertion order (via Self::new_with_insertion_order), different Directory can be passed to Self::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 either 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::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.
first_idx: Option<NodeIndex>Points to the first node index. Populated in the RTL case only.
Implementations§
Source§impl DirectoryGraphBuilder
impl DirectoryGraphBuilder
pub fn new_with_insertion_order(insertion_order: DirectoryOrder) -> Self
pub fn 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§
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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::Request