| Crates.io | ns-keyed-archive |
| lib.rs | ns-keyed-archive |
| version | 0.1.3 |
| created_at | 2025-03-10 02:52:19.814089+00 |
| updated_at | 2025-03-15 04:58:04.500179+00 |
| description | A library to encode/decode NSKeyedArchive binary plists |
| homepage | |
| repository | https://github.com/jkcoxson/ns_keyed_archive |
| max_upload_size | |
| id | 1586090 |
| size | 24,621 |
A library to encode/decode NSKeyedArchive-formatted binary plists Based off the work from NSKeyedArchiver Converter
Add this library and plist to your Cargo.toml
[dependencies]
plist = "1.7"
ns_keyed_archive = "*"
use plist;
// Create a new plist and insert values
let mut d = plist::Dictionary::new();
let a = plist::Value::Array(vec!["a".into(), 1.into()]);
d.insert("reeeeee".to_string(), a);
d.insert("asdf".into(), "qwer".into());
let mut d_d = plist::Dictionary::new();
d_d.insert("fortnite".into(), plist::Value::Boolean(false));
d.insert("good games".into(), d_d.into());
// Encode the binary in an archived binary plist
let b = encode::encode_to_bytes(d.clone().into()).unwrap();
// Decode it again
let d1 = decode::from_bytes(&b).unwrap();
assert_eq!(plist::Value::Dictionary(d), d1);
// Another example
let s = plist::Value::String("asdf".into());
let b = encode::encode_to_bytes(s.clone()).unwrap();
let s1 = decode::from_bytes(&b).unwrap();
assert_eq!(s, s1);