Skip to main content

Storage

Trait Storage 

Source
pub trait Storage: Sync + Send {
Show 19 methods // Required methods fn item_kind(&self) -> ItemKind; 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 delete_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 get_property<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, property: 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: 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: 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<ItemVersion>, 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<(Item, Etag), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn create_item<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, collection: &'life1 str, item: &'life2 Item, opts: CreateItemOptions, ) -> Pin<Box<dyn Future<Output = Result<ItemVersion, 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 Item, ) -> 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 href_for_collection_id(&self, id: &CollectionId) -> Result<Href, Error>; // Provided methods fn list_properties<'life0, 'life1, 'async_trait>( &'life0 self, collection_href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<FetchedProperty>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn get_many_items<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, hrefs: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = Result<Vec<FetchedItem>, 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>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn monitor<'life0, 'async_trait>( &'life0 self, interval: Duration, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn StorageMonitor>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn changed_since<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _collection: &'life1 str, _since_state: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<CollectionChanges, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: '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).

§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 item_kind(&self) -> ItemKind

Return the kind of item this storage can handle.

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 delete_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 get_property<'life0, 'life1, 'async_trait>( &'life0 self, href: &'life1 str, property: 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: 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: 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<ItemVersion>, 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<(Item, 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 create_item<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, collection: &'life1 str, item: &'life2 Item, opts: CreateItemOptions, ) -> Pin<Box<dyn Future<Output = Result<ItemVersion, 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 Item, ) -> 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 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 list_properties<'life0, 'life1, 'async_trait>( &'life0 self, collection_href: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<FetchedProperty>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List all properties of a collection.

Source

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

Fetch all items from a given collection.

§Note for implementers

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

Source

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

Monitor the storage for changes.

Returns a future that resolves into a StorageMonitor instance, which can be polled for new events on the underlying storage.

§Errors

If an error occurs setting up the monitor. In cases where monitoring is not possible due to limitations in the underlying storage, the interval should be used instead.

Source

fn changed_since<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _collection: &'life1 str, _since_state: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<CollectionChanges, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Fetched items that changed since the given sync token.

Enables efficient incremental synchronisation for backends that support collection-level change tracking. Some storages may not support this operation; callers must have a fallback for such situations.

When since_state is None, returns all current items as “changed” along with the initial sync token.

§Errors

Returns ErrorKind::Unsupported if the storage type doesn’t implement state-based change tracking at all (e.g., filesystem, webcal).

Returns ErrorKind::Unavailable if the storage type supports this feature but the specific server doesn’t have it enabled.

Returns other error variants in case of any other error.

Implementors§

Source§

impl Storage for VdirStorage

Source§

impl<C> Storage for CalDavStorage<C>
where C: Service<Request<String>, Response = Response<Incoming>> + Send + Sync + 'static, C::Error: Error + Send + Sync, C::Future: Send + Sync,

Source§

impl<C> Storage for CardDavStorage<C>
where C: Service<Request<String>, Response = Response<Incoming>> + Send + Sync + 'static, C::Error: Error + Send + Sync, C::Future: Send + Sync,

Source§

impl<C> Storage for JmapStorage<C>
where C: Service<Request<String>, Response = Response<Incoming>> + Send + Sync + 'static, C::Error: Error + Send + Sync, C::Future: Send + Sync,

Source§

impl<C> Storage for WebCalStorage<C>
where C: Service<Request<String>, Response = Response<Incoming>> + Send + Sync + Clone + 'static, C::Error: Error + Send + Sync, C::Future: Send + Sync,

Source§

impl<S: Storage> Storage for ReadOnlyStorage<S>