Enum serde_xmlrpc::Value

source ·
pub enum Value {
    Int(i32),
    Int64(i64),
    Bool(bool),
    String(String),
    Double(f64),
    DateTime(DateTime),
    Base64(Vec<u8>),
    Struct(BTreeMap<String, Value>),
    Array(Vec<Value>),
    Nil,
}
Expand description

Represents any single valid xmlrpc “Value”

Variants§

§

Int(i32)

A 32-bit signed integer (<i4> or <int>).

§

Int64(i64)

A 64-bit signed integer (<i8>).

§

Bool(bool)

A boolean value (<boolean>, 0 == false, 1 == true).

§

String(String)

A string (<string>).

§

Double(f64)

A double-precision IEEE 754 floating point number (<double>).

§

DateTime(DateTime)

An ISO 8601 formatted date/time value (<dateTime.iso8601>).

§

Base64(Vec<u8>)

Base64-encoded binary data (<base64>).

§

Struct(BTreeMap<String, Value>)

A mapping of named values (<struct>).

§

Array(Vec<Value>)

A list of arbitrary (heterogeneous) values (<array>).

§

Nil

The empty (Unit) value (<nil/>).

Implementations§

source§

impl Value

source

pub fn as_i32(&self) -> Option<i32>

Returns an inner struct or array value indexed by index.

Returns None if the member doesn’t exist or self is neither a struct nor an array.

You can also use Rust’s square-bracket indexing syntax to perform this operation if you want a default value instead of an Option. Refer to the top-level examples for details. If the Value is a normal integer (Value::Int), returns associated value. Returns None otherwise.

In particular, None is also returned if self is a Value::Int64. Use as_i64 to handle this case.

source

pub fn as_i64(&self) -> Option<i64>

If the Value is an integer, returns associated value. Returns None otherwise.

This works with both Value::Int and Value::Int64.

source

pub fn as_bool(&self) -> Option<bool>

If the Value is a boolean, returns associated value. Returns None otherwise.

source

pub fn as_str(&self) -> Option<&str>

If the Value is a string, returns associated value. Returns None otherwise.

source

pub fn as_f64(&self) -> Option<f64>

If the Value is a floating point number, returns associated value. Returns None otherwise.

source

pub fn as_datetime(&self) -> Option<DateTime>

If the Value is a date/time, returns associated value. Returns None otherwise.

source

pub fn as_bytes(&self) -> Option<&[u8]>

If the Value is base64 binary data, returns associated value. Returns None otherwise.

source

pub fn as_struct(&self) -> Option<&BTreeMap<String, Value>>

If the Value is a struct, returns associated map. Returns None otherwise.

source

pub fn as_array(&self) -> Option<&[Value]>

If the Value is an array, returns associated slice. Returns None otherwise.

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Value

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Value

source§

fn deserialize<D>(deserializer: D) -> Result<Value, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<&str> for Value

source§

fn from(other: &str) -> Self

Converts to this type from the input type.
source§

impl From<BTreeMap<String, Value>> for Value

source§

fn from(other: BTreeMap<String, Value>) -> Value

Converts to this type from the input type.
source§

impl From<DateTime> for Value

source§

fn from(other: DateTime) -> Self

Converts to this type from the input type.
source§

impl From<String> for Value

source§

fn from(other: String) -> Self

Converts to this type from the input type.
source§

impl From<Vec<Value>> for Value

source§

fn from(other: Vec<Value>) -> Value

Converts to this type from the input type.
source§

impl From<Vec<u8>> for Value

source§

fn from(other: Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl From<bool> for Value

source§

fn from(other: bool) -> Self

Converts to this type from the input type.
source§

impl From<f64> for Value

source§

fn from(other: f64) -> Self

Converts to this type from the input type.
source§

impl From<i32> for Value

source§

fn from(other: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for Value

source§

fn from(other: i64) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Value

source§

fn eq(&self, other: &Value) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> TryFrom<&'a Value> for &'a BTreeMap<String, Value>

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a Value> for &'a DateTime

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a Value> for &'a Vec<Value>

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a Value> for &'a Vec<u8>

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a Value> for &'a bool

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a Value> for &'a f64

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a Value> for &'a i64

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a Value> for &'a str

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a Value> for String

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> TryFrom<&'a Value> for i32

§

type Error = ()

The type returned in the event of a conversion error.
source§

fn try_from(value: &'a Value) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,