pub struct ValueRef<'a> { /* private fields */ }Expand description
ValueRef contains a &'a Value
Implementations
sourceimpl<'a> ValueRef<'a>
impl<'a> ValueRef<'a>
sourcepub const fn new(
meta: u8,
user_meta: u8,
expires_at: u64,
version: u64,
data: &'a [u8]
) -> Self
pub const fn new(
meta: u8,
user_meta: u8,
expires_at: u64,
version: u64,
data: &'a [u8]
) -> Self
Returns a ValueRef from byte slice
sourcepub unsafe fn from_raw_value_pointer(rp: RawValuePointer) -> ValueRef<'a>
pub unsafe fn from_raw_value_pointer(rp: RawValuePointer) -> ValueRef<'a>
sourcepub fn to_string(&self) -> String
pub fn to_string(&self) -> String
Converts a slice of bytes to a string, including invalid characters.
sourcepub fn to_lossy_string(&self) -> Cow<'_, str>
pub fn to_lossy_string(&self) -> Cow<'_, str>
Converts a slice of bytes to a string, including invalid characters.
sourcepub fn get_version(&self) -> u64
pub fn get_version(&self) -> u64
Get the value version
Trait Implementations
sourceimpl<'a> ValueExt for ValueRef<'a>
impl<'a> ValueExt for ValueRef<'a>
sourcefn as_value_ref(&self) -> ValueRef<'_>
fn as_value_ref(&self) -> ValueRef<'_>
sourcefn parse_value(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
fn parse_value(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
Returns the value data
sourcefn parse_value_to_bytes(&self) -> Bytes
fn parse_value_to_bytes(&self) -> Bytes
Returns the value data, shallow copy
sourcefn get_user_meta(&self) -> u8
fn get_user_meta(&self) -> u8
Get the user meta
sourcefn get_expires_at(&self) -> u64
fn get_expires_at(&self) -> u64
Returns the expiration time (unix timestamp) for this value
sourcefn encoded_size(&self) -> u32
fn encoded_size(&self) -> u32
Returns the size of the Value when encoded
sourcefn encode(&self, buf: &mut [u8])
fn encode(&self, buf: &mut [u8])
Encode to a mutable slice. This function will copy the value.
Use to_encoded, if you want a shallow copy when encoded. Read more
sourcefn to_encoded(&self) -> EncodedValue
fn to_encoded(&self) -> EncodedValue
Encode to EncodedValue. Read more
sourcefn decode_value_ref(src: &[u8]) -> ValueRef<'_>
fn decode_value_ref(src: &[u8]) -> ValueRef<'_>
Decodes byte slice to value ref.
sourcefn decode_value(src: &[u8]) -> Value
fn decode_value(src: &[u8]) -> Value
Decodes byte slice to value.
sourcefn decode_bytes(src: Bytes) -> Value
fn decode_bytes(src: Bytes) -> Value
Decode bytes to value. (Shallow copy)
sourcefn has_prefix(&self, prefix: impl ValueExt) -> bool
fn has_prefix(&self, prefix: impl ValueExt) -> bool
Returns whether the slice self begins with prefix.
sourcefn has_suffix(&self, suffix: impl ValueExt) -> bool
fn has_suffix(&self, suffix: impl ValueExt) -> bool
Returns whether the slice self ends with suffix.
sourcefn longest_prefix(&self, other: impl ValueExt) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
fn longest_prefix(&self, other: impl ValueExt) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
Finds the longest shared prefix
sourcefn longest_suffix(&self, other: impl ValueExt) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
fn longest_suffix(&self, other: impl ValueExt) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
Finds the longest shared suffix
impl<'a> Copy for ValueRef<'a>
impl<'a> Eq for ValueRef<'a>
impl<'a> StructuralEq for ValueRef<'a>
impl<'a> StructuralPartialEq for ValueRef<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for ValueRef<'a>
impl<'a> Send for ValueRef<'a>
impl<'a> Sync for ValueRef<'a>
impl<'a> Unpin for ValueRef<'a>
impl<'a> UnwindSafe for ValueRef<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more