pub trait DittoDocument {
    // Required methods
    fn id(&self) -> DocumentId;
    fn to_cbor(&self) -> Result<Value, DittoError>;
    fn get<V: DeserializeOwned>(&self, path: &str) -> Result<V, DittoError>;
    fn typed<T: DeserializeOwned>(&self) -> Result<T, DittoError>;
}
Expand description

DittoDocuments can be obtained via calls to the various exec methods or via the various observe_local methods, exposed via the objects returned from calls to Collection::find_by_id, Collection::find, and Collection::find_all.

This is the readonly view of the document as it is currently stored in the Collection and it will not be updated if the document is changed.

Required Methods§

source

fn id(&self) -> DocumentId

Returns the DocumentId of the document.

source

fn to_cbor(&self) -> Result<Value, DittoError>

Renders the document as a CBOR value.

source

fn get<V: DeserializeOwned>(&self, path: &str) -> Result<V, DittoError>

Returns the value at a given path in the document.

The parameter V represents the type expected at the given path. Note, however, that other peers may have changed this type and deserialization may fail. In this case provide a general type like serde_cbor::Value.

source

fn typed<T: DeserializeOwned>(&self) -> Result<T, DittoError>

Decodes a document into a user-provided type provided that type implements serde::Deserialize.

Note that this is a snapshot of the current state of the document, which may be later modified by other peers

Object Safety§

This trait is not object safe.

Implementors§