Skip to main content

ObjectStore

Trait ObjectStore 

Source
pub trait ObjectStore {
    type Get<'a>: Future<Output = Result<Option<Object>>> + 'a
       where Self: 'a;
    type GetRange<'a>: Future<Output = Result<Bytes>> + 'a
       where Self: 'a;
    type Head<'a>: Future<Output = Result<Option<Meta>>> + 'a
       where Self: 'a;
    type Put<'a>: Future<Output = Result<u64>> + 'a
       where Self: 'a;
    type List<'a>: Future<Output = Result<Vec<Meta>>> + 'a
       where Self: 'a;
    type Delete<'a>: Future<Output = Result<()>> + 'a
       where Self: 'a;

    // Required methods
    fn get<'a>(&'a self, key: &'a str) -> Self::Get<'a>;
    fn get_range<'a>(
        &'a self,
        key: &'a str,
        range: Range<u64>,
    ) -> Self::GetRange<'a>;
    fn head<'a>(&'a self, key: &'a str) -> Self::Head<'a>;
    fn put<'a>(&'a self, key: &'a str, body: Bytes, cond: Cond) -> Self::Put<'a>;
    fn list<'a>(&'a self, prefix: &'a str) -> Self::List<'a>;
    fn delete<'a>(&'a self, key: &'a str) -> Self::Delete<'a>;
}
Expand description

An object store with generation preconditions.

Keys are validated by Key::parse: /-separated segments of [A-Za-z0-9._-], no empty segment, none starting with ., at most 1024 bytes.

Implementations must be linearizable per key: a successful conditional write is observed by every later read.

Required Associated Types§

Source

type Get<'a>: Future<Output = Result<Option<Object>>> + 'a where Self: 'a

Future of get.

Source

type GetRange<'a>: Future<Output = Result<Bytes>> + 'a where Self: 'a

Future of get_range.

Source

type Head<'a>: Future<Output = Result<Option<Meta>>> + 'a where Self: 'a

Future of head.

Source

type Put<'a>: Future<Output = Result<u64>> + 'a where Self: 'a

Future of put.

Source

type List<'a>: Future<Output = Result<Vec<Meta>>> + 'a where Self: 'a

Future of list.

Source

type Delete<'a>: Future<Output = Result<()>> + 'a where Self: 'a

Future of delete.

Required Methods§

Source

fn get<'a>(&'a self, key: &'a str) -> Self::Get<'a>

The whole object, or None if it does not exist.

Source

fn get_range<'a>( &'a self, key: &'a str, range: Range<u64>, ) -> Self::GetRange<'a>

Bytes range of the object. A range running past the end is clipped; a range starting at or past the end is an empty body. A missing object is Error::NotFound.

Source

fn head<'a>(&'a self, key: &'a str) -> Self::Head<'a>

Size and generation, without the body.

Source

fn put<'a>(&'a self, key: &'a str, body: Bytes, cond: Cond) -> Self::Put<'a>

Write body under key if cond holds; returns the new generation.

Source

fn list<'a>(&'a self, prefix: &'a str) -> Self::List<'a>

Every object whose key starts with prefix, sorted by key. An empty prefix lists everything; a non-empty prefix is validated like a key (a trailing / is allowed).

Source

fn delete<'a>(&'a self, key: &'a str) -> Self::Delete<'a>

Remove the object. Deleting a missing key succeeds.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ObjectStore for LocalDir

Source§

impl ObjectStore for Mem

Source§

impl<T: TokenProvider> ObjectStore for Gcs<T>

Source§

type Get<'a> = impl Future<Output = Result<Option<Object>, Error>> + 'a where Self: 'a

Source§

type GetRange<'a> = impl Future<Output = Result<Bytes, Error>> + 'a where Self: 'a

Source§

type Head<'a> = impl Future<Output = Result<Option<Meta>, Error>> + 'a where Self: 'a

Source§

type Put<'a> = impl Future<Output = Result<u64, Error>> + 'a where Self: 'a

Source§

type List<'a> = impl Future<Output = Result<Vec<Meta>, Error>> + 'a where Self: 'a

Source§

type Delete<'a> = impl Future<Output = Result<(), Error>> + 'a where Self: 'a