pub struct TypedStreamReader<'a> { /* private fields */ }Expand description
Contains logic and data used to deserialize data from a typedstream.
typedstream is a binary serialization format developed by NeXT and later adopted by Apple.
It’s designed to serialize and deserialize complex object graphs and data structures in C and Objective-C.
A typedstream begins with a header that includes format version and architecture information,
followed by a stream of typed data elements. Each element is prefixed with type information,
allowing the TypedStreamReader to understand the original data structures.
Implementations§
Source§impl<'a> TypedStreamReader<'a>
impl<'a> TypedStreamReader<'a>
Sourcepub fn from(stream: &'a [u8]) -> Self
pub fn from(stream: &'a [u8]) -> Self
Given a stream, construct a reader instance to parse it.
§Example:
use imessage_database::util::typedstream::parser::TypedStreamReader;
let bytes: Vec<u8> = vec![]; // Example stream
let mut reader = TypedStreamReader::from(&bytes);Sourcepub fn parse(&mut self) -> Result<Vec<Archivable>, TypedStreamError>
pub fn parse(&mut self) -> Result<Vec<Archivable>, TypedStreamError>
Attempt to get the data from the typedstream.
Given a stream, construct a reader object to parse it. typedstream data doesn’t include property
names, so data is stored on Objects in order of appearance.
Yields a new Archivable as they occur in the stream, but does not retain the object’s inheritance heirarchy.
Callers are responsible for assembling the deserialized stream into a useful data structure.
§Example:
use imessage_database::util::typedstream::parser::TypedStreamReader;
let bytes: Vec<u8> = vec![]; // Example stream
let mut reader = TypedStreamReader::from(&bytes);
let result = reader.parse();§Sample output:
[
Object(Class { name: "NSMutableString", version: 1 }, [String("Example")]) // The message text
Data([Integer(1), Integer(7)]) // The next object describes properties for the range of chars 1 through 7
Object(Class { name: "NSDictionary", version: 0 }, [Integer(1)]) // The first property is a `NSDictionary` with 1 item
Object(Class { name: "NSString", version: 1 }, [String("__kIMMessagePartAttributeName")]) // The first key in the `NSDictionary`
Object(Class { name: "NSNumber", version: 0 }, [Integer(0)]) // The first value in the `NSDictionary`
]