Expand description
Apple property-list serialization for Rust: XML, binary (bplist00),
OpenStep, and GNUStep — encode and decode.
apple-plist is a serde-native Rust library for Apple property lists.
Unlike most Rust plist crates it targets all four Apple property-list
dialects in both directions, handling the edge cases that show up in
real-world files.
§Quick start
Decoding auto-detects the format; encoding picks the format you name:
use apple_plist::{Format, Value, detect};
let bytes = apple_plist::to_vec(&true, Format::Xml)?;
assert!(bytes.ends_with(b"<true/></plist>"));
let value: Value = apple_plist::from_slice(&bytes)?;
assert_eq!(value, Value::Boolean(true));
assert_eq!(detect(&bytes), Some(Format::Xml));Streaming and Value-tree variants live on Encoder and Decoder;
both compile with every feature combination and work without serde.
§Status
The full surface is implemented: the core data model (Value and its
nine cases, Integer, Real, Date, Uid, the Error
model, Format, the depth bound), all four codecs behind their feature
gates, format auto-detection (detect, the XML-to-text retry ladder),
and the serde bridge (to_vec, from_slice, to_value,
from_value, and friends).
§Cargo features
All on by default; every combination compiles and features only add API:
serde— derive-driven (de)serialization:Encoder::encode,Decoder::decode, and the free functionsto_vec,to_vec_indent,to_writer,from_slice,from_reader,to_value,from_value.xml— the XML codec.binary— the binary (bplist00) codec.openstep— the OpenStep/GNUStep text codec (one feature: the two dialects share a parser, and OpenStep-versus-GNUStep is a runtime outcome).
Decoding a format whose feature is compiled out fails with
Error::InvalidPlist from its rung of the detection ladder; encoding
one fails with Error::FeatureDisabled.
Structs§
- Date
- An absolute point in time: a UTC instant with nanosecond precision.
- Decoder
- Reads one property-list document from a reader, auto-detecting its
Format. - Encoder
- Writes property-list documents to a writer in a chosen
Format. - Real
- A property-list real number.
- Uid
- A
UIDvalue, as found inNSKeyedArchiver/CF$UIDproperty lists.
Enums§
- Error
- Errors returned while encoding or decoding a property list.
- Format
- A property-list serialization format.
- Integer
- A property-list integer, carrying its signedness.
- Value
- Any value a property list can hold.
Constants§
- MAX_
PARSE_ DEPTH - The maximum structural nesting depth any parser descends before returning
Error::MaxDepthExceeded.
Functions§
- detect
- Identifies the property-list format of
data, orNonewhen no enabled codec accepts it. - from_
reader - Deserializes a property-list document from a reader, auto-detecting its format.
- from_
slice - Deserializes a property-list document from a byte slice, auto-detecting its format.
- from_
value - Converts an owned
Valuetree into anyDeserializeOwnedtype, always in strict mode (the lax string coercions are reserved for the OpenStep decode path). - to_
value - Converts any
Serializevalue into an ownedValuetree. - to_vec
- Serializes
valueinto a new byte vector in the given format. - to_
vec_ indent - Serializes
valueinto a new, pretty-printed byte vector. - to_
writer - Serializes
valuetowriterin the given format.
Type Aliases§
- Dictionary
- An order-preserving plist dictionary.
- Result
- A specialized
Resultfor property-list operations.