pub enum LazyJsonValue<'a> {
StringBorrowed(&'a [u8]),
StringOwned(String),
NumberSlice(&'a [u8]),
Boolean(bool),
Null,
ObjectSlice(&'a [u8]),
ArraySlice(&'a [u8]),
}
Expand description
Zero-copy JSON value that references original buffer when possible
Variants§
StringBorrowed(&'a [u8])
String that references original buffer (no escapes)
StringOwned(String)
String that required unescaping (allocated)
NumberSlice(&'a [u8])
Number as slice of original buffer
Boolean(bool)
Boolean value
Null
Null value
ObjectSlice(&'a [u8])
Object as slice of original buffer
ArraySlice(&'a [u8])
Array as slice of original buffer
Implementations§
Source§impl<'a> LazyJsonValue<'a>
impl<'a> LazyJsonValue<'a>
Sourcepub fn value_type(&self) -> ValueType
pub fn value_type(&self) -> ValueType
Get value type
Sourcepub fn to_string_lossy(&self) -> String
pub fn to_string_lossy(&self) -> String
Convert to string (allocating if needed)
Sourcepub fn as_str(&self) -> DomainResult<&str>
pub fn as_str(&self) -> DomainResult<&str>
Try to parse as string without allocation
Sourcepub fn as_number(&self) -> DomainResult<f64>
pub fn as_number(&self) -> DomainResult<f64>
Try to parse as number
Sourcepub fn as_boolean(&self) -> DomainResult<bool>
pub fn as_boolean(&self) -> DomainResult<bool>
Try to parse as boolean
Sourcepub fn memory_usage(&self) -> MemoryUsage
pub fn memory_usage(&self) -> MemoryUsage
Estimate memory usage (allocated vs referenced)
Trait Implementations§
Source§impl<'a> Clone for LazyJsonValue<'a>
impl<'a> Clone for LazyJsonValue<'a>
Source§fn clone(&self) -> LazyJsonValue<'a>
fn clone(&self) -> LazyJsonValue<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> Debug for LazyJsonValue<'a>
impl<'a> Debug for LazyJsonValue<'a>
Source§impl<'a> PartialEq for LazyJsonValue<'a>
impl<'a> PartialEq for LazyJsonValue<'a>
impl<'a> StructuralPartialEq for LazyJsonValue<'a>
Auto Trait Implementations§
impl<'a> Freeze for LazyJsonValue<'a>
impl<'a> RefUnwindSafe for LazyJsonValue<'a>
impl<'a> Send for LazyJsonValue<'a>
impl<'a> Sync for LazyJsonValue<'a>
impl<'a> Unpin for LazyJsonValue<'a>
impl<'a> UnwindSafe for LazyJsonValue<'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
Mutably borrows from an owned value. Read more