Expand description
Parser for Apple Freeform pasteboard data.
A single copy contains several parallel flavors: PencilKit ink, the native
object graph, routing metadata, assets, state flags, text selections, and
rendered fallbacks. decode_pasteboard preserves every supplied flavor,
decodes each tier independently, and reports failures without discarding
tiers that remain usable.
The private CRL formats are reverse-engineered and OS-version fragile. Unsupported records retain their original bytes; truncated, corrupt, and hostile inputs return structured errors instead of fabricated values.
§Example
use libfreeform::{FreeformBlobs, FreeformFlavor, FreeformTier, decode_pasteboard};
let flavors = [
("com.apple.drawing", "com_apple_drawing"),
("com.apple.freeform.CRLNativeData", "com_apple_freeform_CRLNativeData"),
("com.apple.freeform.TSUDescription", "com_apple_freeform_TSUDescription"),
]
.into_iter()
.filter_map(|(uti, path)| {
std::fs::read(path)
.ok()
.map(|bytes| FreeformFlavor { uti: uti.into(), bytes })
})
.collect();
let decoded = decode_pasteboard(FreeformBlobs { change_count: None, flavors });
if let FreeformTier::Decoded(drawing) = decoded.drawing {
for stroke in drawing.strokes {
println!("{} stroke, {} controls", stroke.ink_type, stroke.points.len());
}
}Re-exports§
pub use crl::decode_crl_native;pub use crl::join_crl_tsu;pub use crl::parse_tsu_description;pub use decode::BlobKind;pub use decode::classify_blob;pub use decode::decode_pasteboard;pub use decode::has_freeform_content;pub use pkdrawing::PK_POINT_STRIDE;pub use pkdrawing::decode_pk_drawing;pub use pkdrawing::is_pk_drawing;pub use types::*;
Modules§
- bplist
- Strict Apple binary property list (
bplist00) reader. - crl
- CRL native-archive integration.
- decode
- Lossless pasteboard assembly for Freeform selections.
- pkdrawing
- Decoder for Apple’s
com.apple.drawingPencilKitpasteboard flavor. - types
- Lossless, format-agnostic data produced by the Apple Freeform pasteboard decoders.