Enum rmpv::ValueRef
[−]
[src]
pub enum ValueRef<'a> { Nil, Boolean(bool), Integer(Integer), F32(f32), F64(f64), String(Utf8StringRef<'a>), Binary(&'a [u8]), Array(Vec<ValueRef<'a>>), Map(Vec<(ValueRef<'a>, ValueRef<'a>)>), Ext(i8, &'a [u8]), }
Variants
Nil
Nil represents nil.
Boolean(bool)
Boolean represents true or false.
Integer(Integer)
Integer represents an integer.
A value of an Integer
object is limited from -(2^63)
upto (2^64)-1
.
F32(f32)
A 32-bit floating point number.
F64(f64)
A 64-bit floating point number.
String(Utf8StringRef<'a>)
String extending Raw type represents a UTF-8 string.
Binary(&'a [u8])
Binary extending Raw type represents a byte array.
Array(Vec<ValueRef<'a>>)
Array represents a sequence of objects.
Map(Vec<(ValueRef<'a>, ValueRef<'a>)>)
Map represents key-value pairs of objects.
Ext(i8, &'a [u8])
Extended implements Extension interface: represents a tuple of type information and a byte array where type information is an integer whose meaning is defined by applications.
Methods
impl<'a> ValueRef<'a>
[src]
fn to_owned(&self) -> Value
Converts the current non-owning value to an owned Value.
This is achieved by deep copying all underlying structures and borrowed buffers.
Panics
Panics in unable to allocate memory to keep all internal structures and buffers.
Examples
use rmpv::{Value, ValueRef}; let val = ValueRef::Array(vec![ ValueRef::Nil, ValueRef::from(42), ValueRef::Array(vec![ ValueRef::from("le message"), ]) ]); let expected = Value::Array(vec![ Value::Nil, Value::from(42), Value::Array(vec![ Value::String("le message".into()) ]) ]); assert_eq!(expected, val.to_owned());
fn index(&self, index: usize) -> &ValueRef
fn as_u64(&self) -> Option<u64>
If the ValueRef
is an integer, return or cast it to a u64.
Returns None otherwise.
Examples
use rmpv::ValueRef; assert_eq!(Some(42), ValueRef::from(42).as_u64());
fn as_array(&self) -> Option<&Vec<ValueRef>>
If the ValueRef
is an Array, returns the associated vector.
Returns None otherwise.
Examples
use rmpv::ValueRef; let val = ValueRef::Array(vec![ValueRef::Nil, ValueRef::Boolean(true)]); assert_eq!(Some(&vec![ValueRef::Nil, ValueRef::Boolean(true)]), val.as_array()); assert_eq!(None, ValueRef::Nil.as_array());
fn into_array(self) -> Option<Vec<ValueRef<'a>>>
Trait Implementations
impl<'a> Clone for ValueRef<'a>
[src]
fn clone(&self) -> ValueRef<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<'a> Debug for ValueRef<'a>
[src]
impl<'a> PartialEq for ValueRef<'a>
[src]
fn eq(&self, __arg_0: &ValueRef<'a>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &ValueRef<'a>) -> bool
This method tests for !=
.