pub trait Provider: Send + Sync {
fn head<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
range: Option<(u64, u64)>
) -> Pin<Box<dyn Future<Output = Result<ReadStream<'static>, Error>> + Send + 'async_trait>>
where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn put<'life0, 'life1, 'async_trait>(
&'life0 self,
data: ReadStream<'life1>
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
Specifies a storage backend for the blobnet service.
Each method returns an error only when some operational problem occurs, such as in I/O or communication. Retries should be handled internally by the function since each provider has different failure modes.
This trait was designed to support flexible combinators that can be used to add caching or fallbacks to providers.
Required Methods§
sourcefn head<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn head<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if a file exists and returns its size in bytes.
Equivalent to:
ⓘ
async fn head(&self, hash: &str) -> Result<u64, Error>;
sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
range: Option<(u64, u64)>
) -> Pin<Box<dyn Future<Output = Result<ReadStream<'static>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
range: Option<(u64, u64)>
) -> Pin<Box<dyn Future<Output = Result<ReadStream<'static>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the data from the file at the given path.
Equivalent to:
ⓘ
async fn get(&self, hash: &str, range: Option<(u64, u64)>) -> Result<ReadStream<'static>, Error>;
sourcefn put<'life0, 'life1, 'async_trait>(
&'life0 self,
data: ReadStream<'life1>
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put<'life0, 'life1, 'async_trait>(
&'life0 self,
data: ReadStream<'life1>
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Adds a binary blob to storage, returning its hash.
This function is not as latency-sensitive as the others, caring more about throughput. It may take two passes over the data.
Equivalent to:
ⓘ
async fn put(&self, data: ReadStream<'_>) -> Result<String, Error>;