pub struct DatabaseEntry { /* private fields */ }Expand description
Encodes database key and data items as byte arrays.
Both key and data items are represented by DatabaseEntry objects. Key and data byte arrays may refer to arrays of zero length up to arrays of essentially unlimited length.
Internally uses bytes::Bytes so that clone() is O(1) (reference-count
increment) and from_vec / set_data_vec are zero-copy.
Implementations§
Source§impl DatabaseEntry
impl DatabaseEntry
Sourcepub fn from_bytes(data: &[u8]) -> Self
pub fn from_bytes(data: &[u8]) -> Self
Creates a DatabaseEntry from a byte slice (copies the slice).
Alias: from_data is also available.
Sourcepub fn from_vec(data: Vec<u8>) -> Self
pub fn from_vec(data: Vec<u8>) -> Self
Creates a DatabaseEntry from an owned Vec<u8> — zero-copy.
Sourcepub fn from_bytes_ref(data: Bytes) -> Self
pub fn from_bytes_ref(data: Bytes) -> Self
Creates a DatabaseEntry from an existing Bytes — zero-copy.
Sourcepub fn get_data(&self) -> Option<&[u8]>
pub fn get_data(&self) -> Option<&[u8]>
Gets a reference to the data.
Returns None if the entry is empty, otherwise returns a slice from offset to offset+size.
Sourcepub fn set_data_vec(&mut self, data: Vec<u8>)
pub fn set_data_vec(&mut self, data: Vec<u8>)
Sets the data from an owned Vec<u8> — zero-copy.
Sourcepub fn set_data_bytes(&mut self, data: Bytes)
pub fn set_data_bytes(&mut self, data: Bytes)
Sets the data from an existing Bytes — zero-copy.
Sourcepub fn from_data(data: &[u8]) -> Self
pub fn from_data(data: &[u8]) -> Self
Creates a DatabaseEntry from a byte slice.
Alias for from_bytes.
Sourcepub fn data(&self) -> &[u8] ⓘ
pub fn data(&self) -> &[u8] ⓘ
Gets the data as a byte slice, returning an empty slice if no data.
Convenience method that unwraps the Option from get_data().
Sourcepub fn set_offset(&mut self, offset: usize)
pub fn set_offset(&mut self, offset: usize)
Sets the offset within the data array.
Sourcepub fn get_offset(&self) -> usize
pub fn get_offset(&self) -> usize
Gets the offset within the data array.
Sourcepub fn set_partial(&mut self, offset: usize, length: usize, partial: bool)
pub fn set_partial(&mut self, offset: usize, length: usize, partial: bool)
Configures this entry as a partial entry.
Partial entries are used to read or write only a portion of a record.
Sourcepub fn is_partial(&self) -> bool
pub fn is_partial(&self) -> bool
Returns whether this is a partial entry.
Sourcepub fn get_partial_offset(&self) -> usize
pub fn get_partial_offset(&self) -> usize
Gets the partial offset.
Sourcepub fn get_partial_length(&self) -> usize
pub fn get_partial_length(&self) -> usize
Gets the partial length.
Trait Implementations§
Source§impl Clone for DatabaseEntry
impl Clone for DatabaseEntry
Source§fn clone(&self) -> DatabaseEntry
fn clone(&self) -> DatabaseEntry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DatabaseEntry
impl Debug for DatabaseEntry
Source§impl Default for DatabaseEntry
impl Default for DatabaseEntry
impl Eq for DatabaseEntry
Source§impl From<&[u8]> for DatabaseEntry
impl From<&[u8]> for DatabaseEntry
Source§impl From<&str> for DatabaseEntry
impl From<&str> for DatabaseEntry
Source§impl From<Bytes> for DatabaseEntry
impl From<Bytes> for DatabaseEntry
Source§impl From<String> for DatabaseEntry
impl From<String> for DatabaseEntry
Source§impl PartialEq for DatabaseEntry
impl PartialEq for DatabaseEntry
Source§fn eq(&self, other: &DatabaseEntry) -> bool
fn eq(&self, other: &DatabaseEntry) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for DatabaseEntry
Auto Trait Implementations§
impl !Freeze for DatabaseEntry
impl RefUnwindSafe for DatabaseEntry
impl Send for DatabaseEntry
impl Sync for DatabaseEntry
impl Unpin for DatabaseEntry
impl UnsafeUnpin for DatabaseEntry
impl UnwindSafe for DatabaseEntry
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,
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
key and return true if they are equal.