Trait vstorage::base::Item

source ·
pub trait Item: Sync + Send + Debugwhere
    Self: From<String>,{
    type CollectionProperty: Sync + Send;

    // Required methods
    fn uid(&self) -> Option<String>;
    fn hash(&self) -> String;
    fn ident(&self) -> String;
    fn with_uid(&self, new_uid: &str) -> Self;
    fn as_str(&self) -> &str;
Expand description

A type of item that is contained in a Storage.

A Storage can contain items of a concrete type described by implementations of this trait. This trait defines how to extract the basic information that is required to synchronise storages. Additional parsing is out of scope here and should be done by inspecting the raw data inside an item via Item::as_str.

Required Associated Types§


type CollectionProperty: Sync + Send

Property types supported by storages.

Generally, this type should be an enum with each known property represented as a different variant.

These were known as “metadata” in the previous vdirsyncer implementation.

See also Storage::get_collection_property and Storage::get_collection_property.

Required Methods§


fn uid(&self) -> Option<String>

Parse the item and return a unique identifier for it.

The uid does not change when the item is modified. The uid MUST remain the same when the item is copied across storages and storage types.


fn hash(&self) -> String

Return the hash of this item.

Implementations SHOULD normalise content before hashing to ensure that two equivalent items return the same hash.

This value is used as a fallback when a storage backend doesn’t provide Etag values, or when an item’s Item::uid returns None.


fn ident(&self) -> String

A unique identifier for this item. Is either the UID (if any), or the hash of its contents.


fn with_uid(&self, new_uid: &str) -> Self

Returns a new copy of this Item with the supplied UID.


fn as_str(&self) -> &str

Returns the raw contents of this item.