Enum plist::Value

source ·
#[non_exhaustive]
pub enum Value { Array(Vec<Value>), Dictionary(Dictionary), Boolean(bool), Data(Vec<u8>), Date(Date), Real(f64), Integer(Integer), String(String), Uid(Uid), }
Expand description

Represents any plist value.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Array(Vec<Value>)

§

Dictionary(Dictionary)

§

Boolean(bool)

§

Data(Vec<u8>)

§

Date(Date)

§

Real(f64)

§

Integer(Integer)

§

String(String)

§

Uid(Uid)

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

source

pub fn to_file_binary<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>

Serializes a Value to a file as a binary encoded plist.

source

pub fn to_file_xml<P: AsRef<Path>>(&self, path: P) -> Result<(), Error>

Serializes a Value to a file as an XML encoded plist.

source

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

Serializes a Value to a byte stream as a binary encoded plist.

source

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

Serializes a Value to a byte stream as an XML encoded plist.

source

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

Serializes a Value to a stream, using custom XmlWriteOptions.

If you need to serialize to a file, you must acquire an appropriate Write handle yourself.

§Examples
use std::io::{BufWriter, Write};
use std::fs::File;
use plist::{Dictionary, Value, XmlWriteOptions};

let value: Value = Dictionary::new().into();
// .. add some keys & values
let mut file = File::create("com.example.myPlist.plist").unwrap();
let options = XmlWriteOptions::default().indent_string("  ");
value.to_writer_xml_with_options(BufWriter::new(&mut file), &options).unwrap();
file.sync_all().unwrap();
source

pub fn into_array(self) -> Option<Vec<Value>>

If the Value is a Array, returns the underlying Vec.

Returns None otherwise.

This method consumes the Value. To get a reference instead, use as_array.

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 into_dictionary(self) -> Option<Dictionary>

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

Returns None otherwise.

This method consumes the Value. To get a reference instead, use as_dictionary.

source

pub fn as_dictionary(&self) -> Option<&Dictionary>

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

Returns None otherwise.

source

pub fn as_dictionary_mut(&mut self) -> Option<&mut Dictionary>

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_signed_integer(&self) -> Option<i64>

If the Value is a signed Integer, returns the associated i64.

Returns None otherwise.

source

pub fn as_unsigned_integer(&self) -> Option<u64>

If the Value is an unsigned Integer, returns the associated u64.

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.

source

pub fn into_uid(self) -> Option<Uid>

If the Value is a Uid, returns the underlying Uid.

Returns None otherwise.

This method consumes the Value. If this is not desired, please use as_uid method.

source

pub fn as_uid(&self) -> Option<&Uid>

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

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<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. 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 u64> for Value

source§

fn from(from: &'a u64) -> 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<Date> for Value

source§

fn from(from: Date) -> Value

Converts to this type from the input type.
source§

impl From<Dictionary> for Value

source§

fn from(from: Dictionary) -> 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<u64> for Value

source§

fn from(from: u64) -> 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 Serialize for Value

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

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