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>;
}ditto.store().execute_v2(...) or ditto.store().register_observer_v2(...) insteadExpand 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ยง
Sourcefn id(&self) -> DocumentId
๐Deprecated: Use ditto.store().execute_v2(...) or ditto.store().register_observer_v2(...) instead
fn id(&self) -> DocumentId
ditto.store().execute_v2(...) or ditto.store().register_observer_v2(...) insteadReturns the DocumentId of the document.
Sourcefn to_cbor(&self) -> Result<Value, DittoError>
๐Deprecated: Use ditto.store().execute_v2(...) or ditto.store().register_observer_v2(...) instead
fn to_cbor(&self) -> Result<Value, DittoError>
ditto.store().execute_v2(...) or ditto.store().register_observer_v2(...) insteadRenders the document as a CBOR value.
Sourcefn get<V: DeserializeOwned>(&self, path: &str) -> Result<V, DittoError>
๐Deprecated: Use ditto.store().execute_v2(...) or ditto.store().register_observer_v2(...) instead
fn get<V: DeserializeOwned>(&self, path: &str) -> Result<V, DittoError>
ditto.store().execute_v2(...) or ditto.store().register_observer_v2(...) insteadReturns 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.
Sourcefn typed<T: DeserializeOwned>(&self) -> Result<T, DittoError>
๐Deprecated: Use ditto.store().execute_v2(...) or ditto.store().register_observer_v2(...) instead
fn typed<T: DeserializeOwned>(&self) -> Result<T, DittoError>
ditto.store().execute_v2(...) or ditto.store().register_observer_v2(...) insteadDecodes 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
Dyn Compatibilityยง
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.