Skip to main content

NarSource

Trait NarSource 

Source
pub trait NarSource: Send + Sync {
    // Required method
    fn open<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Bytes, StoreError>> + Send>>, StoreError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided method
    fn size_hint(&self) -> Option<u64> { ... }
}
Expand description

A re-openable NAR byte source.

open yields a fresh bounded-chunk stream over the same bytes every time it is called, so a fan-out writer feeds each destination in order from its own stream and never has to materialize the NAR to serve more than one consumer. See the module docs for why the write side needs this and a plain Stream will not do.

Required Methods§

Source

fn open<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<Bytes, StoreError>> + Send>>, StoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Open a fresh chunk stream over the same bytes.

§Errors

Returns a StoreError if the underlying bytes cannot be (re-)opened — a spool file that was removed, a lower tier that lost the content between the probe and the promotion.

Provided Methods§

Source

fn size_hint(&self) -> Option<u64>

Total byte length if it is known before reading. Backends use it to size a multipart upload or to reject an over-cap value before reading a single byte; None is always legal and must never be load-bearing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§