pub struct Batch {
pub preconditions: Vec<Precondition>,
pub writes: Vec<Write>,
}Expand description
One atomic, declarative write: preconditions, then puts and deletes in order (a later write to the same key wins). A batch with no writes only checks.
Fields§
§preconditions: Vec<Precondition>Checked in order; the first failure aborts the batch.
writes: Vec<Write>Applied in order if every precondition holds.
Implementations§
Source§impl Batch
impl Batch
Sourcepub fn require(self, precondition: Precondition) -> Self
pub fn require(self, precondition: Precondition) -> Self
Append a precondition.
Sourcepub fn has_put(&self) -> bool
pub fn has_put(&self) -> bool
Whether the batch adds data (holds a put): what a full partition
rejects with StoreError::Full.
Sourcepub fn validate(&self, caps: &StoreCapabilities) -> Result<(), StoreError>
pub fn validate(&self, caps: &StoreCapabilities) -> Result<(), StoreError>
Check the batch against the size limits and a store’s capabilities,
before anything is read or written. Every backend calls this first
in NamespaceStore::apply.
§Errors
StoreError::Invalid for a key over MAX_KEY_BYTES, a value
over MAX_VALUE_BYTES (510 KiB for timer payloads), more than
MAX_BATCH_OPS operations or
more than MAX_BATCH_BYTES in total; StoreError::Unsupported
for a key outside caps.key_classes, or, without
atomic_multi_key, more than one write or a key precondition on
another key than the write.