pub struct PolymorphicValue { /* private fields */ }Expand description
Polymorphic value that encodes small values inline
This is the core type for space-efficient value storage. Small values (≤7 bytes) are stored directly without allocation.
§Thread Safety
PolymorphicValue is not thread-safe by default. Use AtomicValue
for concurrent access.
Implementations§
Source§impl PolymorphicValue
impl PolymorphicValue
Sourcepub fn int(v: i64) -> Self
pub fn int(v: i64) -> Self
Create an integer value
Values in range [-2^55, 2^55-1] are stored inline.
Sourcepub fn as_str(&self) -> Option<String>
pub fn as_str(&self) -> Option<String>
Get as string (copies inline data if needed)
For inline strings, returns a new String. For heap strings, returns from heap.
Sourcepub fn as_heap_str(&self) -> Option<&str>
pub fn as_heap_str(&self) -> Option<&str>
Get heap string as reference (only works for heap strings)
Sourcepub fn inline_bytes_copy(&self) -> Option<Vec<u8>>
pub fn inline_bytes_copy(&self) -> Option<Vec<u8>>
Get raw inline bytes (copies out of packed representation)
Sourcepub fn encoded_size(&self) -> usize
pub fn encoded_size(&self) -> usize
Get encoded size in bytes
Sourcepub fn from_bytes(data: &[u8]) -> Option<Self>
pub fn from_bytes(data: &[u8]) -> Option<Self>
Deserialize from bytes
Trait Implementations§
Source§impl Clone for PolymorphicValue
impl Clone for PolymorphicValue
Source§fn clone(&self) -> PolymorphicValue
fn clone(&self) -> PolymorphicValue
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PolymorphicValue
impl Debug for PolymorphicValue
Auto Trait Implementations§
impl Freeze for PolymorphicValue
impl RefUnwindSafe for PolymorphicValue
impl Send for PolymorphicValue
impl Sync for PolymorphicValue
impl Unpin for PolymorphicValue
impl UnsafeUnpin for PolymorphicValue
impl UnwindSafe for PolymorphicValue
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more