Enum simple_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,
}
serde_xmlrpc::Value
insteadVariants§
Int(i32)
serde_xmlrpc::Value
insteadA 32-bit signed integer (<i4>
or <int>
).
Int64(i64)
serde_xmlrpc::Value
insteadA 64-bit signed integer (<i8>
).
Bool(bool)
serde_xmlrpc::Value
insteadA boolean value (<boolean>
, 0 == false
, 1 == true
).
String(String)
serde_xmlrpc::Value
insteadA string (<string>
).
Double(f64)
serde_xmlrpc::Value
insteadA double-precision IEEE 754 floating point number (<double>
).
DateTime(DateTime)
serde_xmlrpc::Value
insteadAn ISO 8601 formatted date/time value (<dateTime.iso8601>
).
Base64(Vec<u8>)
serde_xmlrpc::Value
insteadBase64-encoded binary data (<base64>
).
Struct(BTreeMap<String, Value>)
serde_xmlrpc::Value
insteadA mapping of named values (<struct>
).
Array(Vec<Value>)
serde_xmlrpc::Value
insteadA list of arbitrary (heterogeneous) values (<array>
).
Nil
serde_xmlrpc::Value
insteadThe empty (Unit) value (<nil/>
).
Implementations§
source§impl Value
impl Value
pub fn stringify(&self) -> Result<String>
sourcepub fn as_i32(&self) -> Option<i32>
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.
sourcepub fn as_i64(&self) -> Option<i64>
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
.
sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
If the Value
is a boolean, returns associated value. Returns None
otherwise.
sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
If the Value
is a string, returns associated value. Returns None
otherwise.
sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
If the Value
is a floating point number, returns associated value. Returns None
otherwise.
sourcepub fn as_datetime(&self) -> Option<DateTime>
pub fn as_datetime(&self) -> Option<DateTime>
If the Value
is a date/time, returns associated value. Returns None
otherwise.
sourcepub fn as_bytes(&self) -> Option<&[u8]>
pub fn as_bytes(&self) -> Option<&[u8]>
If the Value
is base64 binary data, returns associated value. Returns None
otherwise.