Trait tvix_store::pathinfoservice::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§