pub struct ReservedSpace<'a> { /* private fields */ }
Expand description
A structure that is used to improve the write speed in LMDB.
You must write the exact amount of bytes, no less, no more.
Implementations§
Source§impl ReservedSpace<'_>
impl ReservedSpace<'_>
Sourcepub fn written_mut(&mut self) -> &mut [u8] ⓘ
pub fn written_mut(&mut self) -> &mut [u8] ⓘ
Get a slice of all the bytes that have previously been written.
This can be used to write information which cannot be known until the very end of serialization. For example, this method can be used to serialize a value, then compute a checksum over the bytes, and then write that checksum to a header at the start of the reserved space.
Sourcepub fn fill_zeroes(&mut self)
pub fn fill_zeroes(&mut self)
Fills the remaining reserved space with zeroes.
This can be used together with written_mut
to get a mutable view of
the entire reserved space.
§Note
After calling this function, the entire space is considered to be filled and any
further attempt to write
anything else will fail.
Sourcepub fn as_uninit_mut(&mut self) -> &mut [MaybeUninit<u8>]
pub fn as_uninit_mut(&mut self) -> &mut [MaybeUninit<u8>]
Get a slice of bytes corresponding to the entire reserved space.
It is safe to write to any byte within the slice. However, for a write past the end of the
prevously written bytes to take effect, assume_written
has to be
called to mark those bytes as initialized.
§Safety
As the memory comes from within the database itself, the bytes may not yet be
initialized. Thus, it is up to the caller to ensure that only initialized memory is read
(ensured by the MaybeUninit
API).
Sourcepub unsafe fn assume_written(&mut self, len: usize)
pub unsafe fn assume_written(&mut self, len: usize)
Marks the bytes in the range 0..len
as being initialized by advancing the internal write
pointer.
§Safety
The caller guarantees that all bytes in the range have been initialized.
Trait Implementations§
Source§impl Debug for ReservedSpace<'_>
impl Debug for ReservedSpace<'_>
Source§impl Seek for ReservedSpace<'_>
impl Seek for ReservedSpace<'_>
§Note
May only seek within the previously written space. Attempts to do otherwise will result in an error.
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
Source§fn stream_position(&mut self) -> Result<u64>
fn stream_position(&mut self) -> Result<u64>
Source§impl Write for ReservedSpace<'_>
impl Write for ReservedSpace<'_>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)Auto Trait Implementations§
impl<'a> Freeze for ReservedSpace<'a>
impl<'a> RefUnwindSafe for ReservedSpace<'a>
impl<'a> Send for ReservedSpace<'a>
impl<'a> Sync for ReservedSpace<'a>
impl<'a> Unpin for ReservedSpace<'a>
impl<'a> !UnwindSafe for ReservedSpace<'a>
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<W> WriteBytesExt for W
impl<W> WriteBytesExt for W
Source§fn write_u8(&mut self, n: u8) -> Result<(), Error>
fn write_u8(&mut self, n: u8) -> Result<(), Error>
Source§fn write_i8(&mut self, n: i8) -> Result<(), Error>
fn write_i8(&mut self, n: i8) -> Result<(), Error>
Source§fn write_u16<T>(&mut self, n: u16) -> Result<(), Error>where
T: ByteOrder,
fn write_u16<T>(&mut self, n: u16) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_i16<T>(&mut self, n: i16) -> Result<(), Error>where
T: ByteOrder,
fn write_i16<T>(&mut self, n: i16) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_u24<T>(&mut self, n: u32) -> Result<(), Error>where
T: ByteOrder,
fn write_u24<T>(&mut self, n: u32) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_i24<T>(&mut self, n: i32) -> Result<(), Error>where
T: ByteOrder,
fn write_i24<T>(&mut self, n: i32) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_u32<T>(&mut self, n: u32) -> Result<(), Error>where
T: ByteOrder,
fn write_u32<T>(&mut self, n: u32) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_i32<T>(&mut self, n: i32) -> Result<(), Error>where
T: ByteOrder,
fn write_i32<T>(&mut self, n: i32) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_u48<T>(&mut self, n: u64) -> Result<(), Error>where
T: ByteOrder,
fn write_u48<T>(&mut self, n: u64) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_i48<T>(&mut self, n: i64) -> Result<(), Error>where
T: ByteOrder,
fn write_i48<T>(&mut self, n: i64) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_u64<T>(&mut self, n: u64) -> Result<(), Error>where
T: ByteOrder,
fn write_u64<T>(&mut self, n: u64) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_i64<T>(&mut self, n: i64) -> Result<(), Error>where
T: ByteOrder,
fn write_i64<T>(&mut self, n: i64) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_u128<T>(&mut self, n: u128) -> Result<(), Error>where
T: ByteOrder,
fn write_u128<T>(&mut self, n: u128) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_i128<T>(&mut self, n: i128) -> Result<(), Error>where
T: ByteOrder,
fn write_i128<T>(&mut self, n: i128) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_uint<T>(&mut self, n: u64, nbytes: usize) -> Result<(), Error>where
T: ByteOrder,
fn write_uint<T>(&mut self, n: u64, nbytes: usize) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_int<T>(&mut self, n: i64, nbytes: usize) -> Result<(), Error>where
T: ByteOrder,
fn write_int<T>(&mut self, n: i64, nbytes: usize) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_uint128<T>(&mut self, n: u128, nbytes: usize) -> Result<(), Error>where
T: ByteOrder,
fn write_uint128<T>(&mut self, n: u128, nbytes: usize) -> Result<(), Error>where
T: ByteOrder,
Source§fn write_int128<T>(&mut self, n: i128, nbytes: usize) -> Result<(), Error>where
T: ByteOrder,
fn write_int128<T>(&mut self, n: i128, nbytes: usize) -> Result<(), Error>where
T: ByteOrder,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes