Struct bonsaidb_core::document::Revision
source · pub struct Revision {
pub id: u32,
pub sha256: [u8; 32],
}
Expand description
Information about a Document
’s revision history.
Fields§
§id: u32
The current revision id of the document. This value is sequentially incremented on each document update.
sha256: [u8; 32]
The SHA256 digest of the bytes contained within the Document
.
Implementations§
source§impl Revision
impl Revision
sourcepub fn new(contents: &[u8]) -> Self
pub fn new(contents: &[u8]) -> Self
Creates the first revision for a document with the SHA256 digest of the passed bytes.
sourcepub fn with_id(id: u32, contents: &[u8]) -> Self
pub fn with_id(id: u32, contents: &[u8]) -> Self
Creates a revision with id
for a document with the SHA256 digest of the passed bytes.
sourcepub fn next_revision(&self, new_contents: &[u8]) -> Option<Self>
pub fn next_revision(&self, new_contents: &[u8]) -> Option<Self>
Creates the next revision in sequence with an updated digest. If the digest doesn’t change, None is returned.
Panics
Panics if id
overflows.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Revision
impl<'de> Deserialize<'de> for Revision
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
source§impl PartialEq for Revision
impl PartialEq for Revision
impl Copy for Revision
impl Eq for Revision
impl StructuralEq for Revision
impl StructuralPartialEq for Revision
Auto Trait Implementations§
impl RefUnwindSafe for Revision
impl Send for Revision
impl Sync for Revision
impl Unpin for Revision
impl UnwindSafe for Revision
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