Trait asuran::repository::backend::Backend [−][src]
pub trait Backend: 'static + Send + Sync + Debug + 'static {
type Manifest: Manifest + 'static;
type Index: Index + 'static;
fn get_index(&self) -> Self::Index;
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;
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;
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;
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;
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;
}
Expand description
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
Required methods
Writes the specified encrypted key to the backend
Returns Err if the key could not be written
Attempts to read the encrypted key from the backend.
fn get_manifest(&self) -> Self::Manifest
fn get_manifest(&self) -> Self::Manifest
Returns a view of this respository’s manifest
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,
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
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,
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
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
fn get_object_handle(&self) -> BackendObject
Creates a new trait-object based BackendHandle
This is required to implement clone for