TypedStreamDeserializer

Struct TypedStreamDeserializer 

Source
pub struct TypedStreamDeserializer<'a> {
    pub data: &'a [u8],
    pub type_table: Vec<Vec<Type<'a>>>,
    pub object_table: Vec<Archived<'a>>,
    /* private fields */
}
Expand description

Contains logic and data used to deserialize data from a typedstream.

typedstream is a binary serialization format developed by NeXTSTEP 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 TypedStreamDeserializer to understand the original data structures.

Fields§

§data: &'a [u8]

The typedstream we want to parse

§type_table: Vec<Vec<Type<'a>>>

As we parse the typedstream, build a table of seen Types to reference in the future

The first time a Type is seen, it is present in the stream literally, but afterwards are only referenced by index in order of appearance.

§object_table: Vec<Archived<'a>>

As we parse the typedstream, build a table of seen Archived data to reference in the future

Implementations§

Source§

impl<'a> TypedStreamDeserializer<'a>

Source

pub fn new(data: &'a [u8]) -> Self

Create a new TypedStreamDeserializer for the provided byte slice.

§Examples
use crabstep::deserializer::typedstream::TypedStreamDeserializer;

let data: &[u8] = &[];
let deserializer = TypedStreamDeserializer::new(data);
Source

pub fn iter_root(&mut self) -> Result<PropertyIterator<'a, '_>>

Creates an iterator that resolves the properties of the root object in the typedstream.

§Examples
use crabstep::deserializer::typedstream::TypedStreamDeserializer;

let data: &[u8] = &[];
let mut deserializer = TypedStreamDeserializer::new(data);

// Walk the object root, printing each primitive value
deserializer.iter_root().into_iter().for_each(|prop| {
   prop.primitives().into_iter().for_each(|data| println!("{data}"));
});
Source

pub fn oxidize(&mut self) -> Result<usize>

Parse the typedstream, consuming header and objects, returning the index of the top-level archived object.

§Errors

Returns a TypedStreamError if parsing fails or the stream ends unexpectedly.

§Examples
use crabstep::TypedStreamDeserializer;

let mut deserializer = TypedStreamDeserializer::new(&[]);
let result = deserializer.oxidize();
Source

pub fn resolve_properties( &self, root_object_index: usize, ) -> Result<PropertyIterator<'a, '_>>

Creates an iterator that resolves the properties of an object at the specified index in the object_table, preserving nested structure.

This should be called after oxidize().

§Arguments
  • root_object_index - Index of the object in the deserializer’s object_table to iterate.
§Errors

Returns TypedStreamError::InvalidPointer if the index is not a valid object reference.

§Examples
use crabstep::TypedStreamDeserializer;

let mut ts = TypedStreamDeserializer::new(&[]);
let root = ts.oxidize().unwrap();

let iter = ts.resolve_properties(root).unwrap();

Auto Trait Implementations§

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, 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.