Enum plist::Value

source ·
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

source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Value, Error>

Reads a Value from a plist file of any encoding.

source

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.

source

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.

source

pub fn to_writer_xml<W: Write>(&self, writer: W) -> Result<(), Error>

Serializes the given data structure as an XML encoded plist file.

source

pub fn from_events<T>(events: T) -> Result<Value, Error>
where T: IntoIterator<Item = Result<Event, Error>>,

Creates a Value from an event source.

source

pub fn into_events(self) -> Vec<Event>

Converts a Value into an Event stream.

source

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

If the Value is an Array, returns the associated Vec.

Returns None otherwise.

source

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.

source

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

If the Value is a Dictionary, returns the associated BTreeMap.

Returns None otherwise.

source

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.

source

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

If the Value is a Boolean, returns the associated bool.

Returns None otherwise.

source

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.

source

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

If the Value is a Data, returns the associated Vec.

Returns None otherwise.

source

pub fn as_date(&self) -> Option<Date>

If the Value is a Date, returns the associated Date.

Returns None otherwise.

source

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

If the Value is a Real, returns the associated f64.

Returns None otherwise.

source

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

If the Value is an Integer, returns the associated i64.

Returns None otherwise.

source

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.

source

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

If the Value is a String, returns the associated str.

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<'a> From<&'a Date> for Value

source§

fn from(from: &'a Date) -> Value

Converts to this type from the input type.
source§

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

source§

fn from(from: &'a bool) -> Value

Converts to this type from the input type.
source§

impl<'a> From<&'a f32> for Value

source§

fn from(from: &'a f32) -> Value

Converts to this type from the input type.
source§

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

source§

fn from(from: &'a f64) -> Value

Converts to this type from the input type.
source§

impl<'a> From<&'a i16> for Value

source§

fn from(from: &'a i16) -> Value

Converts to this type from the input type.
source§

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

source§

fn from(from: &'a i32) -> Value

Converts to this type from the input type.
source§

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

source§

fn from(from: &'a i64) -> Value

Converts to this type from the input type.
source§

impl<'a> From<&'a i8> for Value

source§

fn from(from: &'a i8) -> Value

Converts to this type from the input type.
source§

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

source§

fn from(from: &'a str) -> Value

Converts to this type from the input type.
source§

impl<'a> From<&'a u16> for Value

source§

fn from(from: &'a u16) -> Value

Converts to this type from the input type.
source§

impl<'a> From<&'a u32> for Value

source§

fn from(from: &'a u32) -> Value

Converts to this type from the input type.
source§

impl<'a> From<&'a u8> for Value

source§

fn from(from: &'a u8) -> Value

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

impl From<Date> for Value

source§

fn from(from: Date) -> Value

Converts to this type from the input type.
source§

impl From<String> for Value

source§

fn from(from: String) -> Value

Converts to this type from the input type.
source§

impl From<Vec<Value>> for Value

source§

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

Converts to this type from the input type.
source§

impl From<bool> for Value

source§

fn from(from: bool) -> Value

Converts to this type from the input type.
source§

impl From<f32> for Value

source§

fn from(from: f32) -> Value

Converts to this type from the input type.
source§

impl From<f64> for Value

source§

fn from(from: f64) -> Value

Converts to this type from the input type.
source§

impl From<i16> for Value

source§

fn from(from: i16) -> Value

Converts to this type from the input type.
source§

impl From<i32> for Value

source§

fn from(from: i32) -> Value

Converts to this type from the input type.
source§

impl From<i64> for Value

source§

fn from(from: i64) -> Value

Converts to this type from the input type.
source§

impl From<i8> for Value

source§

fn from(from: i8) -> Value

Converts to this type from the input type.
source§

impl From<u16> for Value

source§

fn from(from: u16) -> Value

Converts to this type from the input type.
source§

impl From<u32> for Value

source§

fn from(from: u32) -> Value

Converts to this type from the input type.
source§

impl From<u8> for Value

source§

fn from(from: u8) -> Value

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 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.