snix_store::pathinfoservice

Trait PathInfoService

Source
pub trait PathInfoService: Send + Sync {
    // Required methods
    fn get<'life0, 'async_trait>(
        &'life0 self,
        digest: [u8; 20],
    ) -> Pin<Box<dyn Future<Output = Result<Option<PathInfo>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn put<'life0, 'async_trait>(
        &'life0 self,
        path_info: PathInfo,
    ) -> Pin<Box<dyn Future<Output = Result<PathInfo, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>>;

    // Provided method
    fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>> { ... }
}
Expand description

The base trait all PathInfo services need to implement.

Required Methods§

Source

fn get<'life0, 'async_trait>( &'life0 self, digest: [u8; 20], ) -> Pin<Box<dyn Future<Output = Result<Option<PathInfo>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve a PathInfo message by the output digest.

Source

fn put<'life0, 'async_trait>( &'life0 self, path_info: PathInfo, ) -> Pin<Box<dyn Future<Output = Result<PathInfo, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Store a PathInfo message. Implementations MUST call validate and reject invalid messages.

Source

fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>>

Iterate over all PathInfo objects in the store. Implementations can decide to disallow listing.

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.

Provided Methods§

Source

fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>>

Returns a (more) suitable NarCalculationService. This can be used to offload NAR calculation to the remote side.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a + PathInfoService + ?Sized> PathInfoService for &'a T
where &'a T: Send + Sync,

Source§

fn get<'life0, 'async_trait>( &'life0 self, digest: [u8; 20], ) -> Pin<Box<dyn Future<Output = Result<Option<PathInfo>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn put<'life0, 'async_trait>( &'life0 self, path_info: PathInfo, ) -> Pin<Box<dyn Future<Output = Result<PathInfo, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>>

Source§

fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>>

Source§

impl<'a, T: 'a + PathInfoService + ?Sized> PathInfoService for &'a mut T
where &'a mut T: Send + Sync,

Source§

fn get<'life0, 'async_trait>( &'life0 self, digest: [u8; 20], ) -> Pin<Box<dyn Future<Output = Result<Option<PathInfo>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn put<'life0, 'async_trait>( &'life0 self, path_info: PathInfo, ) -> Pin<Box<dyn Future<Output = Result<PathInfo, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>>

Source§

fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>>

Source§

impl<T: PathInfoService + ?Sized> PathInfoService for Box<T>
where Box<T>: Send + Sync,

Source§

fn get<'life0, 'async_trait>( &'life0 self, digest: [u8; 20], ) -> Pin<Box<dyn Future<Output = Result<Option<PathInfo>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn put<'life0, 'async_trait>( &'life0 self, path_info: PathInfo, ) -> Pin<Box<dyn Future<Output = Result<PathInfo, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>>

Source§

fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>>

Source§

impl<T: PathInfoService + ?Sized> PathInfoService for Arc<T>
where Arc<T>: Send + Sync,

Source§

fn get<'life0, 'async_trait>( &'life0 self, digest: [u8; 20], ) -> Pin<Box<dyn Future<Output = Result<Option<PathInfo>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn put<'life0, 'async_trait>( &'life0 self, path_info: PathInfo, ) -> Pin<Box<dyn Future<Output = Result<PathInfo, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn list(&self) -> BoxStream<'static, Result<PathInfo, Error>>

Source§

fn nar_calculation_service(&self) -> Option<Box<dyn NarCalculationService>>

Implementors§