[][src]Trait asuran::repository::backend::Backend

pub trait Backend: 'static + Send + Sync + Debug + 'static {
    type Manifest: Manifest + 'static;
    type Index: Index + 'static;
    fn get_index(&self) -> Self::Index;
#[must_use] fn write_key<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 EncryptedKey
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn read_key<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<EncryptedKey>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_manifest(&self) -> Self::Manifest;
#[must_use] fn read_chunk<'life0, 'async_trait>(
        &'life0 mut self,
        location: SegmentDescriptor
    ) -> Pin<Box<dyn Future<Output = Result<Chunk>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn write_chunk<'life0, 'async_trait>(
        &'life0 mut self,
        chunk: Chunk
    ) -> Pin<Box<dyn Future<Output = Result<SegmentDescriptor>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn close<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_object_handle(&self) -> BackendObject; }

Repository backend

The backend handles the heavy lifiting of the IO, abstracting the repository struct itself away from the details of the system used to store the repository.

While the backend trait itself does not require Clone, most uses will require that Backends be Clone, as expressed by the BackendClone trait.

Backend itself can not require clone, for object saftey

Associated Types

type Manifest: Manifest + 'static

type Index: Index + 'static

Loading content...

Required methods

fn get_index(&self) -> Self::Index

Returns a view of the index of the repository

#[must_use] fn write_key<'life0, 'life1, 'async_trait>(
    &'life0 self,
    key: &'life1 EncryptedKey
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Writes the specified encrypted key to the backend

Returns Err if the key could not be written

#[must_use] fn read_key<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<EncryptedKey>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

Attempts to read the encrypted key from the backend.

fn get_manifest(&self) -> Self::Manifest

Returns a view of this respository's manifest

#[must_use] fn read_chunk<'life0, 'async_trait>(
    &'life0 mut self,
    location: SegmentDescriptor
) -> Pin<Box<dyn Future<Output = Result<Chunk>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

Starts reading a chunk from the backend

The chunk will be written to the oneshot once reading is complete

#[must_use] fn write_chunk<'life0, 'async_trait>(
    &'life0 mut self,
    chunk: Chunk
) -> Pin<Box<dyn Future<Output = Result<SegmentDescriptor>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

Starts writing a chunk to the backend

A segment descriptor describing it will be written to oneshot once reading is complete

This must be passed owned data because it will be sent into a task, so the caller has no control over drop time

#[must_use] fn close<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

Consumes the current backend handle, and does any work necessary to close out the backend properly

This is separate from Drop due to the current lack of async drop

This method takes &mut self such that it can be called on trait objects. It is not correct to call any methods on a Backend after close has returned

fn get_object_handle(&self) -> BackendObject

Creates a new trait-object based BackendHandle

This is required to implement clone for

Loading content...

Implementors

impl Backend for MultiFile[src]

type Manifest = Manifest

type Index = Index

fn get_index(&self) -> Self::Index[src]

Clones the internal MFManifest

fn get_manifest(&self) -> Self::Manifest[src]

Clones the internal MFIndex

fn write_key<'life0, 'life1, 'async_trait>(
    &'life0 self,
    key: &'life1 EncryptedKey
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Locks the keyfile and writes the key

Will return Err if writing the key fails

fn read_key<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<EncryptedKey>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Attempts to read the key from the repository

Returns Err if the key doesn't exist or of another error occurs

fn read_chunk<'life0, 'async_trait>(
    &'life0 mut self,
    location: SegmentDescriptor
) -> Pin<Box<dyn Future<Output = Result<Chunk>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Starts reading a chunk, and returns a oneshot recieve with the result of that process

fn write_chunk<'life0, 'async_trait>(
    &'life0 mut self,
    chunk: Chunk
) -> Pin<Box<dyn Future<Output = Result<SegmentDescriptor>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Starts writing a chunk, and returns a oneshot reciever with the result of that process

fn close<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Closes out the index, segment handler, and manifest cleanly, making sure all operations are completed and all drop impls from inside the tasks are called

impl Backend for BackendObject[src]

type Manifest = ManifestObject

type Index = IndexObject

impl<B: SyncBackend> Backend for BackendHandle<B>[src]

type Manifest = Self

type Index = Self

impl<T: Backend> Backend for BackendWrapper<T>[src]

type Manifest = ManifestObject

type Index = IndexObject

Loading content...