Trait vstorage::base::Storage

source ·
pub trait Storage<I: Item>: Sync + Send {
Show 18 methods // Required methods fn check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn discover_collections<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Discovery, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn create_collection<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Collection, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn destroy_collection<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn list_properties<'life0, 'life1, 'async_trait>( &'life0 self, collection_href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<ListedProperty<I::Property>>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_property<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, property: I::Property, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn set_property<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, href: &'life1 str, property: I::Property, value: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn unset_property<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, property: I::Property, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn list_items<'life0, 'life1, 'async_trait>( &'life0 self, collection_href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<ItemRef>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_item<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(I, Etag), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn add_item<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, collection: &'life1 str, item: &'life2 I, ) -> Pin<Box<dyn Future<Output = Result<ItemRef, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn update_item<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, href: &'life1 str, etag: &'life2 Etag, item: &'life3 I, ) -> Pin<Box<dyn Future<Output = Result<Etag, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn delete_item<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, href: &'life1 str, etag: &'life2 Etag, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn collection_id( &self, collection_href: &str, ) -> Result<CollectionId, Error>; fn href_for_collection_id(&self, id: &CollectionId) -> Result<Href, Error>; // Provided methods fn get_many_items<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, hrefs: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = Result<Vec<FetchedItem<I>>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn get_all_items<'life0, 'life1, 'async_trait>( &'life0 self, collection: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<FetchedItem<I>>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn monitor<'life0, 'async_trait>( &'life0 self, bufsize: NonZeroUsize, ) -> Pin<Box<dyn Future<Output = Result<Receiver<Event>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... }
}
Expand description

A storage is the highest level abstraction where items can be stored. It can be a remote CalDav account, a local filesystem, etc.

Each storage may contain one or more collections (e.g.: calendars or address books).

The specific type of item that a storage can hold is defined by the I generic parameter. E.g.: a CalDav storage can hold icalendar items. Only items with the same kind of item can be synchronised with each other (e.g.: it it nos possible to synchronise Storage<VcardItem> with Storage<IcsItem>

§Note for implementors

The auto-generated documentation for this trait is rather hard to read due to the usage of #[async_trait] macro. You might want to consider clicking on the source link and reading the documentation from the raw code for this trait.

Required Methods§

source

fn check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Checks that the storage works. This includes validating credentials, and reachability.

§Errors

Returns an error if the storage is not reachable and usable.

source

fn discover_collections<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Discovery, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Finds existing collections for this storage.

source

fn create_collection<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Collection, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Creates a new collection with a specified href.

source

fn destroy_collection<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes an existing collection.

A collection must be empty for deletion to succeed.

source

fn list_properties<'life0, 'life1, 'async_trait>( &'life0 self, collection_href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<ListedProperty<I::Property>>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all properties of a collection.

source

fn get_property<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, property: I::Property, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns the value of a property for a given collection.

source

fn set_property<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, href: &'life1 str, property: I::Property, value: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Sets the value of a property for a given collection.

source

fn unset_property<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, property: I::Property, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Unsets a property for a given collection.

source

fn list_items<'life0, 'life1, 'async_trait>( &'life0 self, collection_href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<ItemRef>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Enumerates items in a given collection.

source

fn get_item<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(I, Etag), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches a single item from given collection.

Storages never cache data locally. For reading items in bulk, prefer Storage::get_many_items.

source

fn add_item<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, collection: &'life1 str, item: &'life2 I, ) -> Pin<Box<dyn Future<Output = Result<ItemRef, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Saves a new item into a given collection

source

fn update_item<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, href: &'life1 str, etag: &'life2 Etag, item: &'life3 I, ) -> Pin<Box<dyn Future<Output = Result<Etag, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Updates the contents of an existing item.

source

fn delete_item<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, href: &'life1 str, etag: &'life2 Etag, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Deletes an existing item.

source

fn collection_id(&self, collection_href: &str) -> Result<CollectionId, Error>

Return the id for a collection with the given href.

The id for a given Collection must never change. Usually this is based off the last component of the href, but may be different for storages where this does not make sense.

§Errors

This functions returns an Err variant if the provided collection is invalid.

source

fn href_for_collection_id(&self, id: &CollectionId) -> Result<Href, Error>

Return the href for a collection that is expected to have id.

Creating a collection under href SHOULD result in the collection being available via discovery with the provided id.

§Errors

Returns an error if no collection can exist such that it is available via discovery AND its CollectionId matches the input.

Provided Methods§

source

fn get_many_items<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, hrefs: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = Result<Vec<FetchedItem<I>>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Fetches multiple items.

Similar to Storage::get_item, but optimised to minimise the amount of IO required. Duplicate hrefs are ignored.

All requested items MUST belong to the same collection.

§Note for implementers

The default implementation is usually not optimal, and implementations of this trait should override it.

source

fn get_all_items<'life0, 'life1, 'async_trait>( &'life0 self, collection: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<FetchedItem<I>>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch all items from a given collection.

§Note for implementors

The default implementation is usually not optimal, and implementations of this trait should override it.

source

fn monitor<'life0, 'async_trait>( &'life0 self, bufsize: NonZeroUsize, ) -> Pin<Box<dyn Future<Output = Result<Receiver<Event>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Monitor the storage for changes.

Returns the Receiver of a channel which receives Event instances when changes are detected.

§Errors

The default implementation returns ErrorKind::Unsupported.

Implementors§