Struct TypedStreamReader

Source
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>

Source

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);
Source

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`
]

Trait Implementations§

Source§

impl<'a> Debug for TypedStreamReader<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for TypedStreamReader<'a>

§

impl<'a> RefUnwindSafe for TypedStreamReader<'a>

§

impl<'a> Send for TypedStreamReader<'a>

§

impl<'a> Sync for TypedStreamReader<'a>

§

impl<'a> Unpin for TypedStreamReader<'a>

§

impl<'a> UnwindSafe for TypedStreamReader<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.