pub struct Tombstone {
pub actor: Vec<u8>,
pub timestamp_millis: u64,
pub causal_metadata: BTreeMap<String, Vec<u8>>,
}Expand description
Logical deletion value with causal metadata.
The actor identifies who or what performed the delete. The timestamp is a caller-provided Unix millisecond value. Causal metadata is sorted by key when encoded, making the byte representation deterministic.
Fields§
§actor: Vec<u8>Actor that created the tombstone.
timestamp_millis: u64Unix timestamp in milliseconds supplied by the caller.
causal_metadata: BTreeMap<String, Vec<u8>>Application-defined causal metadata.
Implementations§
Source§impl Tombstone
impl Tombstone
Sourcepub fn new(actor: impl Into<Vec<u8>>, timestamp_millis: u64) -> Self
pub fn new(actor: impl Into<Vec<u8>>, timestamp_millis: u64) -> Self
Create a tombstone with no causal metadata.
Sourcepub fn with_causal_metadata(
self,
key: impl Into<String>,
value: impl Into<Vec<u8>>,
) -> Self
pub fn with_causal_metadata( self, key: impl Into<String>, value: impl Into<Vec<u8>>, ) -> Self
Add causal metadata and return the tombstone for chaining.
Sourcepub fn insert_causal_metadata(
&mut self,
key: impl Into<String>,
value: impl Into<Vec<u8>>,
) -> &mut Self
pub fn insert_causal_metadata( &mut self, key: impl Into<String>, value: impl Into<Vec<u8>>, ) -> &mut Self
Insert or replace one causal metadata entry.
Sourcepub fn causal_metadata(&self, key: &str) -> Option<&[u8]>
pub fn causal_metadata(&self, key: &str) -> Option<&[u8]>
Borrow one causal metadata value.
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>, Error>
pub fn to_bytes(&self) -> Result<Vec<u8>, Error>
Encode this tombstone as deterministic bytes suitable for a leaf value.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
Decode a tombstone envelope.
Sourcepub fn from_stored_bytes(bytes: &[u8]) -> Result<Option<Self>, Error>
pub fn from_stored_bytes(bytes: &[u8]) -> Result<Option<Self>, Error>
Decode stored bytes, returning Ok(None) for non-tombstone values.
Values that start with the tombstone magic but contain an invalid tombstone envelope return an error.
Sourcepub fn is_encoded(bytes: &[u8]) -> bool
pub fn is_encoded(bytes: &[u8]) -> bool
Return true if bytes start with the tombstone magic prefix.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tombstone
impl<'de> Deserialize<'de> for Tombstone
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>,
impl Eq for Tombstone
impl StructuralPartialEq for Tombstone
Auto Trait Implementations§
impl Freeze for Tombstone
impl RefUnwindSafe for Tombstone
impl Send for Tombstone
impl Sync for Tombstone
impl Unpin for Tombstone
impl UnsafeUnpin for Tombstone
impl UnwindSafe for Tombstone
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more