pub struct Directory {
nodes: BTreeMap<PathComponent, Node>,
}
Expand description
A Directory contains nodes, which can be Directory, File or Symlink nodes. It attaches names to these nodes, which is the basename in that directory. These names:
- MUST not contain slashes or null bytes
- MUST not be ‘.’ or ‘..’
- MUST be unique across all three lists
Fields§
§nodes: BTreeMap<PathComponent, Node>
Implementations§
Source§impl Directory
impl Directory
Sourcepub fn try_from_iter<T: IntoIterator<Item = (PathComponent, Node)>>(
iter: T,
) -> Result<Directory, DirectoryError>
pub fn try_from_iter<T: IntoIterator<Item = (PathComponent, Node)>>( iter: T, ) -> Result<Directory, DirectoryError>
Sourcepub fn size(&self) -> u64
pub fn size(&self) -> u64
The size of a directory is the number of all regular and symlink elements, the number of directory elements, and their size fields.
Sourcepub fn digest(&self) -> B3Digest
pub fn digest(&self) -> B3Digest
Calculates the digest of a Directory, which is the blake3 hash of a Directory protobuf message, serialized in protobuf canonical form.
Sourcepub fn nodes(
&self,
) -> impl Iterator<Item = (&PathComponent, &Node)> + Send + Sync + '_
pub fn nodes( &self, ) -> impl Iterator<Item = (&PathComponent, &Node)> + Send + Sync + '_
Allows iterating over all nodes (directories, files and symlinks) For each, it returns a tuple of its name and node. The elements are sorted by their names.
Sourcepub fn into_nodes(
self,
) -> impl Iterator<Item = (PathComponent, Node)> + Send + Sync
pub fn into_nodes( self, ) -> impl Iterator<Item = (PathComponent, Node)> + Send + Sync
Dissolves a Directory into its individual names and nodes. The elements are sorted by their names.
Sourcepub fn add(
&mut self,
name: PathComponent,
node: Node,
) -> Result<(), DirectoryError>
pub fn add( &mut self, name: PathComponent, node: Node, ) -> Result<(), DirectoryError>
Adds the specified Node to the Directory with a given name.
Inserting a node that already exists with the same name in the directory will yield an error, as well as exceeding the maximum size.
In case you want to construct a Directory from multiple elements, use Directory::try_from_iter instead.
Trait Implementations§
Source§impl RootNodes for Directory
impl RootNodes for Directory
Source§fn get_by_basename<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 PathComponent,
) -> Pin<Box<dyn Future<Output = Result<Option<Node>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_by_basename<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 PathComponent,
) -> Pin<Box<dyn Future<Output = Result<Option<Node>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
impl Eq for Directory
impl StructuralPartialEq for Directory
Auto Trait Implementations§
impl Freeze for Directory
impl RefUnwindSafe for Directory
impl Send for Directory
impl Sync for Directory
impl Unpin for Directory
impl UnwindSafe for Directory
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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