pub trait DirectoryService: Send + Sync {
// Required methods
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 B3Digest,
) -> Pin<Box<dyn Future<Output = Result<Option<Directory>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn put<'life0, 'async_trait>(
&'life0 self,
directory: Directory,
) -> Pin<Box<dyn Future<Output = Result<B3Digest, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_recursive(
&self,
root_directory_digest: &B3Digest,
) -> BoxStream<'static, Result<Directory, Error>>;
fn put_multiple_start(&self) -> Box<dyn DirectoryPutter>;
}
Expand description
The base trait all Directory services need to implement. This is a simple get and put of Directory, returning their digest.
Required Methods§
sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 B3Digest,
) -> Pin<Box<dyn Future<Output = Result<Option<Directory>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
digest: &'life1 B3Digest,
) -> Pin<Box<dyn Future<Output = Result<Option<Directory>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Looks up a single Directory message by its digest. The returned Directory message must be valid. In case the directory is not found, Ok(None) is returned.
It is okay for certain implementations to only allow retrieval of Directory digests that are at the “root”, aka the last element that’s sent to a DirectoryPutter. This makes sense for implementations bundling closures of directories together in batches.
sourcefn put<'life0, 'async_trait>(
&'life0 self,
directory: Directory,
) -> Pin<Box<dyn Future<Output = Result<B3Digest, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn put<'life0, 'async_trait>(
&'life0 self,
directory: Directory,
) -> Pin<Box<dyn Future<Output = Result<B3Digest, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Uploads a single Directory message, and returns the calculated digest, or an error. An error must also be returned if the message is not valid.
sourcefn get_recursive(
&self,
root_directory_digest: &B3Digest,
) -> BoxStream<'static, Result<Directory, Error>>
fn get_recursive( &self, root_directory_digest: &B3Digest, ) -> BoxStream<'static, Result<Directory, Error>>
Looks up a closure of Directory.
Ideally this would be a impl Stream<Item = Result<Directory, Error>>
,
and we’d be able to add a default implementation for it here, but
we can’t have that yet.
This returns a pinned, boxed stream. The pinning allows for it to be polled easily, and the box allows different underlying stream implementations to be returned since Rust doesn’t support this as a generic in traits yet. This is the same thing that async_trait generates, but for streams instead of futures.
The individually returned Directory messages must be valid. Directories are sent in an order from the root to the leaves, so that the receiving side can validate each message to be a connected to the root that has initially been requested.
In case the directory can not be found, this should return an empty stream.
sourcefn put_multiple_start(&self) -> Box<dyn DirectoryPutter>
fn put_multiple_start(&self) -> Box<dyn DirectoryPutter>
Allows persisting a closure of Directory, which is a graph of connected Directory messages.