ValueRef

Struct ValueRef 

Source
pub struct ValueRef<'a> { /* private fields */ }
Expand description

ValueRef contains a &'a Value

Implementations§

Source§

impl<'a> ValueRef<'a>

Source

pub const fn new( meta: u8, user_meta: u8, expires_at: u64, version: u64, data: &'a [u8], ) -> Self

Returns a ValueRef from byte slice

Source

pub unsafe fn from_raw_value_pointer(rp: RawValuePointer) -> ValueRef<'a>

Returns a ValueRef from RawKeyPointer

§Safety

The inner raw pointer of RawKeyPointer must be valid.

Source

pub fn to_string(&self) -> String

Converts a slice of bytes to a string, including invalid characters.

Source

pub fn to_lossy_string(&self) -> Cow<'_, str>

Converts a slice of bytes to a string, including invalid characters.

Source

pub fn to_value(&self) -> Value

Copy the data to a new value

Source

pub fn get_version(&self) -> u64

Get the value version

Source

pub fn set_version(&mut self, version: u64)

Set the value version for this value ref

Trait Implementations§

Source§

impl<'a> Clone for ValueRef<'a>

Source§

fn clone(&self) -> ValueRef<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for ValueRef<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Hash for ValueRef<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> Ord for ValueRef<'a>

Source§

fn cmp(&self, other: &ValueRef<'a>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a> PartialEq for ValueRef<'a>

Source§

fn eq(&self, other: &ValueRef<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialOrd for ValueRef<'a>

Source§

fn partial_cmp(&self, other: &ValueRef<'a>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> ValueExt for ValueRef<'a>

Source§

fn as_value_ref(&self) -> ValueRef<'_>

Returns a ValueRef
Source§

fn parse_value(&self) -> &[u8]

Returns the value data
Source§

fn parse_value_to_bytes(&self) -> Bytes

Returns the value data (do shallow copy, except RawValuePointer)
Source§

fn get_meta(&self) -> u8

Get the meta of the value
Source§

fn get_user_meta(&self) -> u8

Get the user meta
Source§

fn get_expires_at(&self) -> u64

Returns the expiration time (unix timestamp) for this value
Source§

fn encoded_size(&self) -> u32

Returns the size of the Value when encoded
Source§

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
Source§

fn encode_to_buf(&self, buf: impl BufMut)

Encode to a mutable buf. This function will copy the value. Use to_encoded, if you want a shallow copy when encoded. Read more
Source§

fn to_encoded(&self) -> EncodedValue

Source§

fn decode_value_ref(src: &[u8]) -> ValueRef<'_>

Decodes byte slice to value ref.
Source§

fn decode_value(src: &[u8]) -> Value

Decodes byte slice to value.
Source§

fn decode_bytes(src: Bytes) -> Value

Decode bytes to value. (Shallow copy)
Source§

fn has_prefix(&self, prefix: impl ValueExt) -> bool

Returns whether the slice self begins with prefix.
Source§

fn has_suffix(&self, suffix: impl ValueExt) -> bool

Returns whether the slice self ends with suffix.
Source§

fn longest_prefix(&self, other: impl ValueExt) -> &[u8]

Finds the longest shared prefix
Source§

fn longest_suffix(&self, other: impl ValueExt) -> &[u8]

Finds the longest shared suffix
Source§

fn longest_prefix_lossy(&self, other: impl ValueExt) -> Cow<'_, [u8]>

Finds the longest shared prefix, return a Cow<’_, u8>.
Source§

fn longest_suffix_lossy(&self, other: impl ValueExt) -> Cow<'_, [u8]>

Finds the longest shared suffix, return a Cow<’_, u8>.
Source§

impl<'a> Copy for ValueRef<'a>

Source§

impl<'a> Eq for ValueRef<'a>

Source§

impl<'a> StructuralPartialEq for ValueRef<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for ValueRef<'a>

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.