[][src]Trait asuran::repository::backend::common::sync_backend::SyncBackend

pub trait SyncBackend: 'static + Debug {
    type SyncManifest: SyncManifest + 'static;
    type SyncIndex: SyncIndex + 'static;
    fn get_index(&mut self) -> &mut Self::SyncIndex;
fn get_manifest(&mut self) -> &mut Self::SyncManifest;
fn write_key(&mut self, key: EncryptedKey) -> Result<()>;
fn read_key(&mut self) -> Result<EncryptedKey>;
fn read_chunk(&mut self, location: SegmentDescriptor) -> Result<Chunk>;
fn write_chunk(&mut self, chunk: Chunk) -> Result<SegmentDescriptor>; }

Note: In this version of the trait, the get index and get archive methods return mutable references, instead of owned values. As this version of the trait is intrinsically single threaded, implementers are expected to own a single instance of their Index and Manifest impls, and the reference will never leak outside of their container task.

Also note, that we do not have the close method, as the wrapper type will handle that for us.

Associated Types

type SyncManifest: SyncManifest + 'static

type SyncIndex: SyncIndex + 'static

Loading content...

Required methods

fn get_index(&mut self) -> &mut Self::SyncIndex

fn get_manifest(&mut self) -> &mut Self::SyncManifest

fn write_key(&mut self, key: EncryptedKey) -> Result<()>

fn read_key(&mut self) -> Result<EncryptedKey>

fn read_chunk(&mut self, location: SegmentDescriptor) -> Result<Chunk>

fn write_chunk(&mut self, chunk: Chunk) -> Result<SegmentDescriptor>

Loading content...

Implementors

impl SyncBackend for FlatFile[src]

type SyncManifest = Self

type SyncIndex = Self

impl SyncBackend for Mem[src]

type SyncManifest = Self

type SyncIndex = Self

impl SyncBackend for SFTP[src]

type SyncManifest = SFTPManifest

type SyncIndex = SFTPIndex

impl<F: Read + Write + Seek + 'static> SyncBackend for GenericFlatFile<F>[src]

type SyncManifest = Self

type SyncIndex = Self

fn write_key(&mut self, _key: EncryptedKey) -> Result<()>[src]

This operation is not currently supported for FlatFile repositories, so we just return an error

fn read_key(&mut self) -> Result<EncryptedKey>[src]

Return the cached EncryptedKey

fn read_chunk(&mut self, location: SegmentDescriptor) -> Result<Chunk>[src]

Glue together information from the cached index, the length_map, and the chunk_headers map to find the chunk in the file and reconstruct it.

Errors

  • If there is an underlying I/O error
  • If the location is not present in the length map (the chunk has not been seen before, or it has not been written with write_chunk
  • If the header is not present in the chunk_headers map
Loading content...