vstorage::base

Trait Item

source
pub trait Item:
    Sync
    + Send
    + Debug
    + Clone
where Self: From<String>,
{ type Property: Property; // Required methods fn uid(&self) -> Option<String>; fn hash(&self) -> String; fn with_uid(&self, new_uid: &str) -> Self; fn as_str(&self) -> &str; // Provided method fn ident(&self) -> String { ... } }
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§

source

type Property: Property

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 original vdirsyncer implementation.

See also Storage::get_property and Storage::set_property.

Required Methods§

source

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 remains the same when the item is copied across storages and storage types.

source

fn hash(&self) -> String

Return the hash of this item, usually normalised.

Implementations SHOULD normalise content before hashing to ensure that two semantically 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.

source

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

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

source

fn as_str(&self) -> &str

Returns the raw contents of this item.

Provided Methods§

source

fn ident(&self) -> String

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

Object Safety§

This trait is not object safe.

Implementors§