RepositoryWriter

Trait RepositoryWriter 

Source
pub trait RepositoryWriter: Sync {
    // Required methods
    fn verify_path<'path, 'life0, 'async_trait>(
        &'life0 self,
        path: &'path str,
        expected_content: Option<(u64, ContentDigest)>,
    ) -> Pin<Box<dyn Future<Output = Result<RepositoryPathVerification<'path>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'path: 'async_trait,
             'life0: 'async_trait;
    fn write_path<'path, 'reader, 'life0, 'async_trait>(
        &'life0 self,
        path: Cow<'path, str>,
        reader: Pin<Box<dyn AsyncRead + Send + 'reader>>,
    ) -> Pin<Box<dyn Future<Output = Result<RepositoryWrite<'path>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'path: 'async_trait,
             'reader: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn copy_from<'path, 'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        reader: &'life1 dyn RepositoryRootReader,
        source_path: Cow<'path, str>,
        expected_content: Option<(u64, ContentDigest)>,
        dest_path: Cow<'path, str>,
        progress_cb: &'life2 Option<Box<dyn Fn(PublishEvent) + Sync>>,
    ) -> Pin<Box<dyn Future<Output = Result<RepositoryWriteOperation<'path>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'path: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

An interface for writing to a repository.

From the perspective of this trait, writing to a repository is a matter of providing I/O for testing for path/key existence/integrity and storing new data under a path/key. Additional logic about what to write where is implemented elsewhere.

Required Methods§

Source

fn verify_path<'path, 'life0, 'async_trait>( &'life0 self, path: &'path str, expected_content: Option<(u64, ContentDigest)>, ) -> Pin<Box<dyn Future<Output = Result<RepositoryPathVerification<'path>>> + Send + 'async_trait>>
where Self: 'async_trait, 'path: 'async_trait, 'life0: 'async_trait,

Verify the existence of a path with optional content integrity checking.

If the size and digest are Some implementations may perform additional content integrity verification. Or they may not. They should not lie about whether integrity verification was performed in the returned value, however.

Source

fn write_path<'path, 'reader, 'life0, 'async_trait>( &'life0 self, path: Cow<'path, str>, reader: Pin<Box<dyn AsyncRead + Send + 'reader>>, ) -> Pin<Box<dyn Future<Output = Result<RepositoryWrite<'path>>> + Send + 'async_trait>>
where Self: 'async_trait, 'path: 'async_trait, 'reader: 'async_trait, 'life0: 'async_trait,

Write data to a given path.

The data to write is provided by an AsyncRead reader.

Provided Methods§

Source

fn copy_from<'path, 'life0, 'life1, 'life2, 'async_trait>( &'life0 self, reader: &'life1 dyn RepositoryRootReader, source_path: Cow<'path, str>, expected_content: Option<(u64, ContentDigest)>, dest_path: Cow<'path, str>, progress_cb: &'life2 Option<Box<dyn Fn(PublishEvent) + Sync>>, ) -> Pin<Box<dyn Future<Output = Result<RepositoryWriteOperation<'path>>> + Send + 'async_trait>>
where Self: 'async_trait, 'path: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Copy a path from a reader to this writer.

The source reader is a RepositoryRootReader and the path is relative to the repository root.

The default implementation verifies the integrity of the destination and will no-op if the desired content is already present.

Implementations of this trait may have a custom implementation that changes semantics. For example, a writer could operate in a dry-run mode where it doesn’t actually attempt any I/O. Custom implementations should call progress_cb with events, as appropriate.

Implementors§