pub struct Document {
pub id: DocumentId,
pub title: String,
pub value: CrdtValue,
pub created_at: u64,
pub modified_at: u64,
pub metadata: HashMap<String, String>,
}Expand description
A document with metadata.
Fields§
§id: DocumentIdDocument ID.
title: StringDocument title/name.
value: CrdtValueThe CRDT value.
created_at: u64Creation timestamp.
modified_at: u64Last modified timestamp.
metadata: HashMap<String, String>Document metadata.
Implementations§
Source§impl Document
impl Document
Sourcepub fn new_text(
id: DocumentId,
title: impl Into<String>,
replica_id: &str,
) -> Self
pub fn new_text( id: DocumentId, title: impl Into<String>, replica_id: &str, ) -> Self
Create a new text document.
Sourcepub fn new_rich_text(
id: DocumentId,
title: impl Into<String>,
replica_id: &str,
) -> Self
pub fn new_rich_text( id: DocumentId, title: impl Into<String>, replica_id: &str, ) -> Self
Create a new rich text document.
Sourcepub fn new_json(
id: DocumentId,
title: impl Into<String>,
replica_id: &str,
) -> Self
pub fn new_json( id: DocumentId, title: impl Into<String>, replica_id: &str, ) -> Self
Create a new JSON document.
Sourcepub fn document_type(&self) -> DocumentType
pub fn document_type(&self) -> DocumentType
Get the document type.
Sourcepub fn get_metadata(&self, key: &str) -> Option<&String>
pub fn get_metadata(&self, key: &str) -> Option<&String>
Get metadata.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Document
impl<'de> Deserialize<'de> for Document
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more