pub enum Value {
Array(Vec<Value>),
Dictionary(BTreeMap<String, Value>),
Boolean(bool),
Data(Vec<u8>),
Date(Date),
Real(f64),
Integer(i64),
String(String),
}
Expand description
Represents any plist value.
Variants§
Array(Vec<Value>)
Dictionary(BTreeMap<String, Value>)
Boolean(bool)
Data(Vec<u8>)
Date(Date)
Real(f64)
Integer(i64)
String(String)
Implementations§
source§impl Value
impl Value
sourcepub fn from_file<P: AsRef<Path>>(path: P) -> Result<Value, Error>
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Value, Error>
Reads a Value
from a plist file of any encoding.
sourcepub fn from_reader<R: Read + Seek>(reader: R) -> Result<Value, Error>
pub fn from_reader<R: Read + Seek>(reader: R) -> Result<Value, Error>
Reads a Value
from a seekable byte stream containing a plist file of any encoding.
sourcepub fn from_reader_xml<R: Read>(reader: R) -> Result<Value, Error>
pub fn from_reader_xml<R: Read>(reader: R) -> Result<Value, Error>
Reads a Value
from a seekable byte stream containing an XML encoded plist file.
sourcepub fn to_writer_xml<W: Write>(&self, writer: W) -> Result<(), Error>
pub fn to_writer_xml<W: Write>(&self, writer: W) -> Result<(), Error>
Serializes the given data structure as an XML encoded plist file.
sourcepub fn from_events<T>(events: T) -> Result<Value, Error>
pub fn from_events<T>(events: T) -> Result<Value, Error>
Creates a Value
from an event source.
sourcepub fn into_events(self) -> Vec<Event>
pub fn into_events(self) -> Vec<Event>
Converts a Value
into an Event
stream.
sourcepub fn as_array(&self) -> Option<&Vec<Value>>
pub fn as_array(&self) -> Option<&Vec<Value>>
If the Value
is an Array, returns the associated Vec
.
Returns None
otherwise.
sourcepub fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>
pub fn as_array_mut(&mut self) -> Option<&mut Vec<Value>>
If the Value
is an Array, returns the associated mutable Vec
.
Returns None
otherwise.
sourcepub fn as_dictionary(&self) -> Option<&BTreeMap<String, Value>>
pub fn as_dictionary(&self) -> Option<&BTreeMap<String, Value>>
If the Value
is a Dictionary, returns the associated BTreeMap
.
Returns None
otherwise.
sourcepub fn as_dictionary_mut(&mut self) -> Option<&mut BTreeMap<String, Value>>
pub fn as_dictionary_mut(&mut self) -> Option<&mut BTreeMap<String, Value>>
If the Value
is a Dictionary, returns the associated mutable BTreeMap
.
Returns None
otherwise.
sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
If the Value
is a Boolean, returns the associated bool
.
Returns None
otherwise.
sourcepub fn into_data(self) -> Option<Vec<u8>>
pub fn into_data(self) -> Option<Vec<u8>>
If the Value
is a Data, returns the underlying Vec
.
Returns None
otherwise.
This method consumes the Value
. If this is not desired, please use
as_data
method.
sourcepub fn as_data(&self) -> Option<&[u8]>
pub fn as_data(&self) -> Option<&[u8]>
If the Value
is a Data, returns the associated Vec
.
Returns None
otherwise.
sourcepub fn as_date(&self) -> Option<Date>
pub fn as_date(&self) -> Option<Date>
If the Value
is a Date, returns the associated Date
.
Returns None
otherwise.
sourcepub fn as_real(&self) -> Option<f64>
pub fn as_real(&self) -> Option<f64>
If the Value
is a Real, returns the associated f64
.
Returns None
otherwise.
sourcepub fn as_integer(&self) -> Option<i64>
pub fn as_integer(&self) -> Option<i64>
If the Value
is an Integer, returns the associated i64
.
Returns None
otherwise.
sourcepub fn into_string(self) -> Option<String>
pub fn into_string(self) -> Option<String>
If the Value
is a String, returns the underlying String
.
Returns None
otherwise.
This method consumes the Value
. If this is not desired, please use
as_string
method.