diff --git a/snix/castore/src/fs/root_nodes.rs b/snix/castore/src/fs/root_nodes.rs index 3f75e35f6..016c73c40 100644 --- a/snix/castore/src/fs/root_nodes.rs +++ b/snix/castore/src/fs/root_nodes.rs @@ -1,5 +1,6 @@ use std::collections::BTreeMap; +use crate::nodes::Directory; use crate::{path::PathComponent, Error, Node}; use futures::stream::BoxStream; use tonic::async_trait; @@ -37,3 +38,20 @@ where )) } } + +#[async_trait] +impl RootNodes for Directory { + async fn get_by_basename(&self, name: &PathComponent) -> Result, Error> { + Ok(self + .nodes() + .find(|(key, _)| *key == name) + .map(|(_, node)| node.clone())) + } + + fn list(&self) -> BoxStream> { + Box::pin(tokio_stream::iter( + self.nodes() + .map(|(name, node)| Ok((name.to_owned(), node.to_owned()))), + )) + } +}