Struct linera_views::batch::Batch
source · pub struct Batch {
pub operations: Vec<WriteOperation>,
}
Expand description
A batch of write operations.
Fields§
§operations: Vec<WriteOperation>
The write operations.
Implementations§
source§impl Batch
impl Batch
sourcepub fn num_operations(&self) -> usize
pub fn num_operations(&self) -> usize
Returns the number of operations in this Batch
.
sourcepub async fn build<F>(builder: F) -> Result<Self, ViewError>
pub async fn build<F>(builder: F) -> Result<Self, ViewError>
Builds a batch from a builder function.
sourcepub fn simplify(self) -> UnorderedBatch
pub fn simplify(self) -> UnorderedBatch
Simplifies the batch by removing operations that are overwritten by others.
A key may appear multiple times in the batch, as an insert, a delete or matched by a delete prefix.
let mut batch = Batch::new();
batch.put_key_value(vec![0, 1], &(34 as u128));
batch.delete_key(vec![0, 1]);
let unordered_batch = batch.simplify();
assert_eq!(unordered_batch.key_prefix_deletions.len(), 0);
assert_eq!(unordered_batch.simple_unordered_batch.insertions.len(), 0);
assert_eq!(unordered_batch.simple_unordered_batch.deletions.len(), 1);
sourcepub fn check_value_size(&self, max_value_size: usize) -> bool
pub fn check_value_size(&self, max_value_size: usize) -> bool
Checks the size of the values of the batch.
sourcepub fn put_key_value(
&mut self,
key: Vec<u8>,
value: &impl Serialize,
) -> Result<(), Error>
pub fn put_key_value( &mut self, key: Vec<u8>, value: &impl Serialize, ) -> Result<(), Error>
Adds the insertion of a key-value pair into the batch with a serializable value.
let mut batch = Batch::new();
batch.put_key_value(vec![0, 1], &(34 as u128));
sourcepub fn put_key_value_bytes(&mut self, key: Vec<u8>, value: Vec<u8>)
pub fn put_key_value_bytes(&mut self, key: Vec<u8>, value: Vec<u8>)
Adds the insertion of a (key, value)
pair into the batch with value
a vector of u8
.
let mut batch = Batch::new();
batch.put_key_value_bytes(vec![0, 1], vec![3, 4, 5]);
sourcepub fn delete_key(&mut self, key: Vec<u8>)
pub fn delete_key(&mut self, key: Vec<u8>)
Inserts the deletion of a key
into the batch.
let mut batch = Batch::new();
batch.delete_key(vec![0, 1]);
sourcepub fn delete_key_prefix(&mut self, key_prefix: Vec<u8>)
pub fn delete_key_prefix(&mut self, key_prefix: Vec<u8>)
Inserts the deletion of a key_prefix
into the batch.
let mut batch = Batch::new();
batch.delete_key_prefix(vec![0, 1]);
Trait Implementations§
source§impl PartialEq for Batch
impl PartialEq for Batch
impl Eq for Batch
impl StructuralPartialEq for Batch
Auto Trait Implementations§
impl Freeze for Batch
impl RefUnwindSafe for Batch
impl Send for Batch
impl Sync for Batch
impl Unpin for Batch
impl UnwindSafe for Batch
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.
source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.
source§impl<T> MockResults for T
impl<T> MockResults for T
§type Results = T
type Results = T
The mock native type of the results for the
MockInstance
.source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
source§fn read<'instance>(
&self,
instance: &'instance &mut I,
location: GuestPointer,
length: u32,
) -> Result<Cow<'instance, [u8]>, RuntimeError>
fn read<'instance>( &self, instance: &'instance &mut I, location: GuestPointer, length: u32, ) -> Result<Cow<'instance, [u8]>, RuntimeError>
Reads length
bytes from memory from the provided location
.
source§fn write(
&mut self,
instance: &mut &mut I,
location: GuestPointer,
bytes: &[u8],
) -> Result<(), RuntimeError>
fn write( &mut self, instance: &mut &mut I, location: GuestPointer, bytes: &[u8], ) -> Result<(), RuntimeError>
Writes the bytes
to memory at the provided location
.
source§impl<T> Upcastable for T
impl<T> Upcastable for T
source§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
source§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref