Enum rmp::value::ValueRef [] [src]

pub enum ValueRef<'a> {
    Nil,
    Boolean(bool),
    Integer(Integer),
    Float(Float),
    String(&'a str),
    Binary(&'a [u8]),
    Array(Vec<ValueRef<'a>>),
    Map(Vec<(ValueRef<'a>, ValueRef<'a>)>),
    Ext(i8, &'a [u8]),
}

Variants

Nil

Nil represents nil.

Boolean

Boolean represents true or false.

Integer

Integer represents an integer.

Float

Float represents a floating point number.

String

String extending Raw type represents a UTF-8 string.

Binary

Binary extending Raw type represents a byte array.

Array

Array represents a sequence of objects.

Map

Map represents key-value pairs of objects.

Ext

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>

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 rmp::{Value, ValueRef};
use rmp::value::Integer;

let val = ValueRef::Array(vec![
   ValueRef::Nil,
   ValueRef::Integer(Integer::U64(42)),
   ValueRef::Array(vec![
       ValueRef::String("le message"),
   ])
]);

let expected = Value::Array(vec![
    Value::Nil,
    Value::Integer(Integer::U64(42)),
    Value::Array(vec![
        Value::String("le message".to_string())
    ])
]);

assert_eq!(expected, val.to_owned());

Trait Implementations

Derived Implementations

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

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

fn ne(&self, __arg_0: &ValueRef<'a>) -> bool

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

fn fmt(&self, __arg_0: &mut Formatter) -> Result

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

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

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