Crate plist

Source
Expand description

§Plist

A rusty plist parser.

§Usage

Put this in your Cargo.toml:

[dependencies]
plist = "1"

And put this in your crate root:

extern crate plist;

§Examples

§Using serde

extern crate plist;
#[macro_use]
extern crate serde_derive;

#[derive(Deserialize)]
#[serde(rename_all = "PascalCase")]
struct Book {
    title: String,
    author: String,
    excerpt: String,
    copies_sold: u64,
}

let book: Book = plist::from_file("tests/data/book.plist")
    .expect("failed to read book.plist");

assert_eq!(book.title, "Great Expectations");

§Using Value

use plist::Value;

let book = Value::from_file("tests/data/book.plist")
    .expect("failed to read book.plist");

let title = book
    .as_dictionary()
    .and_then(|dict| dict.get("Title"))
    .and_then(|title| title.as_string());

assert_eq!(title, Some("Great Expectations"));

§Unstable Features

Many features from previous versions are now hidden behind the enable_unstable_features_that_may_break_with_minor_version_bumps feature. These will break in minor version releases after the 1.0 release. If you really really must use them you should specify a tilde requirement e.g. plist = "~1.0.3" in you Cargo.toml so that the plist crate is not automatically updated to version 1.1.

Re-exports§

pub use dictionary::Dictionary;

Modules§

dictionary
A map of String to plist::Value.

Structs§

Data
A byte buffer used for serialization to and from the plist data type.
Date
A UTC timestamp used for serialization to and from the plist date type.
Error
This type represents all possible errors that can occur when working with plist data.
Integer
An integer that can be represented by either an i64 or a u64.
InvalidXmlDate
An error indicating that a string was not a valid XML plist date.
Uid
A plist uid value. These are found exclusively in plists created by NSKeyedArchiver.
XmlWriteOptions
Options for customizing serialization of XML plists.

Enums§

Value
Represents any plist value.

Functions§

from_bytes
Deserializes an instance of type T from a byte slice.
from_file
Deserializes an instance of type T from a plist file of any encoding.
from_reader
Deserializes an instance of type T from a seekable byte stream containing a plist of any encoding.
from_reader_ascii
Deserializes an instance of type T from a byte stream containing an ASCII encoded plist.
from_reader_xml
Deserializes an instance of type T from a byte stream containing an XML encoded plist.
from_value
Interprets a Value as an instance of type T.
to_file_binary
Serializes the given data structure to a file as a binary encoded plist.
to_file_xml
Serializes the given data structure to a file as an XML encoded plist.
to_value
Converts a T into a Value which can represent any valid plist.
to_writer_binary
Serializes the given data structure to a byte stream as a binary encoded plist.
to_writer_xml
Serializes the given data structure to a byte stream as an XML encoded plist.
to_writer_xml_with_options
Serializes to a byte stream as an XML encoded plist, using custom XmlWriteOptions.