Trait dittolive_ditto::store::collection::document::DittoDocument
source · [−]pub trait DittoDocument {
fn id(&self) -> DocumentId;
fn to_cbor(&self) -> Result<Value, DittoError>;
fn get<V: DeserializeOwned>(&self, path: &str) -> Result<V, DittoError>;
fn get_rga(&self, path: &str) -> Result<DittoRga, DittoError>;
fn typed<T: DeserializeOwned>(&self) -> Result<T, DittoError>;
}
Required Methods
sourcefn id(&self) -> DocumentId
fn id(&self) -> DocumentId
Returns the ID of the document
sourcefn to_cbor(&self) -> Result<Value, DittoError>
fn to_cbor(&self) -> Result<Value, DittoError>
Renders the document as a CBOR value
sourcefn get<V: DeserializeOwned>(&self, path: &str) -> Result<V, DittoError>
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
fn get_rga(&self, path: &str) -> Result<DittoRga, DittoError>
sourcefn typed<T: DeserializeOwned>(&self) -> Result<T, DittoError>
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