Enum expry::DecodedValue
source · [−]pub enum DecodedValue<'a> {
Null(),
Bool(bool),
Int(i64),
Float(f32),
Double(f64),
String(&'a [u8]),
Object(DecodedObject<'a>),
Array(DecodedArray<'a>),
}
Expand description
The central data type of Binary. It is modelled similar to JSON, however, contains a couple of noteworthy differences.
The differences with JSON:
- Floats are either 32-bits or 64-bits;
- All strings are u8: they can contain both text or binary data.
Variants
Null()
Bool(bool)
Int(i64)
Signed 64-bits integer (that is packed into smaller value in the wire format if possible).
Float(f32)
32-bits float type.
Double(f64)
64-bits float type.
String(&'a [u8])
Can be both binary data as regular strings. So not necessary UTF-8 (like Rust strings).
Object(DecodedObject<'a>)
Array(DecodedArray<'a>)
Implementations
sourceimpl<'a> DecodedValue<'a>
impl<'a> DecodedValue<'a>
pub fn is_valid_json(&self) -> bool
sourceimpl<'a> DecodedValue<'a>
impl<'a> DecodedValue<'a>
pub const fn type_string(&self) -> &'static str
sourcepub fn size_of_binary(&self, compact: bool) -> usize
pub fn size_of_binary(&self, compact: bool) -> usize
Returns the size needed if we serialize the Binary to a binary wire-format.
See DecodedValue::print_binary()
for explanation of the compact
argument.
sourcepub fn print_binary<E, Out: RawOutput<E>>(
&self,
writer: &mut Out,
compact: bool
) -> Result<(), E>
pub fn print_binary<E, Out: RawOutput<E>>(
&self,
writer: &mut Out,
compact: bool
) -> Result<(), E>
Converts a Binary to a wire representation of that Binary. This wire representation can be sent to other implementations as it is stable and ‘endian safe’.
For objects we have a compact
representation and one that inserts hints how to process the wire-representation faster when
using an expression to evaluate the Binary to another value. This is controlled with the
compact
argument.
This function expects that the writer
has enough room. The needed room can be queried
beforehand by using the DecodedValue::size_of_binary
.
sourcepub fn to_vec(&self, compact: bool) -> ValueVec
pub fn to_vec(&self, compact: bool) -> ValueVec
Converts a Binary to a wire representation of that Binary, in a self contained ValueVec
unsing DecodedValue::print_binary
.
sourcepub fn to_scope<'c>(
&self,
scope: &mut MemoryScope<'c>,
compact: bool
) -> ValueRef<'c>
pub fn to_scope<'c>(
&self,
scope: &mut MemoryScope<'c>,
compact: bool
) -> ValueRef<'c>
Converts a Binary to a wire representation of that Binary, in a self contained ValueVec
unsing DecodedValue::print_binary
.
sourcepub fn print_json(&self, writer: &mut Vec<u8>) -> Result<(), Utf8Error>
pub fn print_json(&self, writer: &mut Vec<u8>) -> Result<(), Utf8Error>
Convert a Binary value to a JSON output.
Note that some Binary values can not be encoded, because not all strings can be encoded as UTF-8. If this is the case, this method will result in a Utf8Error
.
pub fn clone_in<'b>(&self, scope: &mut MemoryScope<'b>) -> DecodedValue<'b>
sourceimpl<'a> DecodedValue<'a>
impl<'a> DecodedValue<'a>
pub fn decoded_type_of(type_and_length: u64) -> Result<ValueType, EncodingError>
sourcepub const fn type_of_binary(type_and_length: u64) -> u8
pub const fn type_of_binary(type_and_length: u64) -> u8
Based on a variable length integer read for the wire, return the ValueType
raw number.
sourcepub const fn length_of_binary(type_and_length: u64) -> usize
pub const fn length_of_binary(type_and_length: u64) -> usize
Based on a variable length integer read for the wire, return the length of the current entry.
pub fn decoded_type_and_length(
type_and_length: u64
) -> Result<(ValueType, usize), EncodingError>
sourcepub fn parse(
reader: &mut RawReader<'a>
) -> Result<DecodedValue<'a>, EncodingError>
pub fn parse(
reader: &mut RawReader<'a>
) -> Result<DecodedValue<'a>, EncodingError>
Parse the wire-format.
sourceimpl<'a> DecodedValue<'a>
impl<'a> DecodedValue<'a>
pub fn parse_json<'c>(
reader: &'a str,
allocator: &mut MemoryScope<'c>
) -> Result<DecodedValue<'a>, CompileError<'a>> where
'c: 'a,
Trait Implementations
sourceimpl<'a> Clone for DecodedValue<'a>
impl<'a> Clone for DecodedValue<'a>
sourcefn clone(&self) -> DecodedValue<'a>
fn clone(&self) -> DecodedValue<'a>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'a> Debug for DecodedValue<'a>
impl<'a> Debug for DecodedValue<'a>
sourceimpl<'a> Display for DecodedValue<'a>
impl<'a> Display for DecodedValue<'a>
sourceimpl<'a> From<&'_ BytecodeRef<'a>> for DecodedValue<'a>
impl<'a> From<&'_ BytecodeRef<'a>> for DecodedValue<'a>
sourcefn from(v: &BytecodeRef<'a>) -> Self
fn from(v: &BytecodeRef<'a>) -> Self
Converts to this type from the input type.
sourceimpl<'a> From<&'_ DecodedValue<'a>> for DecodedValue<'a>
impl<'a> From<&'_ DecodedValue<'a>> for DecodedValue<'a>
sourcefn from(v: &DecodedValue<'a>) -> Self
fn from(v: &DecodedValue<'a>) -> Self
Converts to this type from the input type.
sourceimpl<'a> From<&'_ bool> for DecodedValue<'a>
impl<'a> From<&'_ bool> for DecodedValue<'a>
sourceimpl<'a> From<&'_ f32> for DecodedValue<'a>
impl<'a> From<&'_ f32> for DecodedValue<'a>
sourceimpl<'a> From<&'_ f64> for DecodedValue<'a>
impl<'a> From<&'_ f64> for DecodedValue<'a>
sourceimpl<'a> From<&'_ i64> for DecodedValue<'a>
impl<'a> From<&'_ i64> for DecodedValue<'a>
sourceimpl<'a, T: 'a, const N: usize> From<&'a &'a [T; N]> for DecodedValue<'a> where
DecodedValue<'a>: From<&'a T>,
T: Clone,
impl<'a, T: 'a, const N: usize> From<&'a &'a [T; N]> for DecodedValue<'a> where
DecodedValue<'a>: From<&'a T>,
T: Clone,
sourceimpl<'a, T> From<&'a &'a [T]> for DecodedValue<'a> where
DecodedValue<'a>: From<&'a T>,
impl<'a, T> From<&'a &'a [T]> for DecodedValue<'a> where
DecodedValue<'a>: From<&'a T>,
sourceimpl<'a> From<&'a &'a String> for DecodedValue<'a>
impl<'a> From<&'a &'a String> for DecodedValue<'a>
sourceimpl<'a> From<&'a &'a str> for DecodedValue<'a>
impl<'a> From<&'a &'a str> for DecodedValue<'a>
sourceimpl<'a> From<&'a BytecodeVec> for DecodedValue<'a>
impl<'a> From<&'a BytecodeVec> for DecodedValue<'a>
sourcefn from(v: &'a BytecodeVec) -> Self
fn from(v: &'a BytecodeVec) -> Self
Converts to this type from the input type.
sourceimpl<'a, T: 'a> From<&'a Option<T>> for DecodedValue<'a> where
DecodedValue<'a>: From<&'a T>,
impl<'a, T: 'a> From<&'a Option<T>> for DecodedValue<'a> where
DecodedValue<'a>: From<&'a T>,
sourceimpl<'a> From<&'a String> for DecodedValue<'a>
impl<'a> From<&'a String> for DecodedValue<'a>
sourceimpl<'a, T> From<&'a Vec<T, Global>> for DecodedValue<'a> where
DecodedValue<'a>: From<&'a T>,
impl<'a, T> From<&'a Vec<T, Global>> for DecodedValue<'a> where
DecodedValue<'a>: From<&'a T>,
sourceimpl<'a> From<&'a str> for DecodedValue<'a>
impl<'a> From<&'a str> for DecodedValue<'a>
sourceimpl<'a> PartialEq<DecodedValue<'a>> for DecodedValue<'a>
impl<'a> PartialEq<DecodedValue<'a>> for DecodedValue<'a>
sourcefn eq(&self, other: &DecodedValue<'a>) -> bool
fn eq(&self, other: &DecodedValue<'a>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &DecodedValue<'a>) -> bool
fn ne(&self, other: &DecodedValue<'a>) -> bool
This method tests for !=
.
impl<'a> StructuralPartialEq for DecodedValue<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for DecodedValue<'a>
impl<'a> Send for DecodedValue<'a>
impl<'a> Sync for DecodedValue<'a>
impl<'a> Unpin for DecodedValue<'a>
impl<'a> UnwindSafe for DecodedValue<'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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more