Struct apple_xar::reader::XarReader

source ·
pub struct XarReader<R: Read + Seek + Sized + Debug> { /* private fields */ }
Expand description

Read-only interface to a single XAR archive.

Implementations§

source§

impl<R: Read + Seek + Sized + Debug> XarReader<R>

source

pub fn new(reader: R) -> XarResult<Self>

Construct a new XAR reader from a stream reader.

source

pub fn into_inner(self) -> R

Obtain the inner reader.

source

pub fn header(&self) -> &XarHeader

Obtain the parsed XarHeader file header.

source

pub fn heap_start_offset(&self) -> u64

The start offset of the heap.

source

pub fn table_of_contents(&self) -> &TableOfContents

Obtain the table of contents for this archive.

source

pub fn table_of_contents_decoded_data(&mut self) -> XarResult<Vec<u8>>

Obtain the decoded content of the table of contents.

source

pub fn checksum_data(&mut self) -> XarResult<Vec<u8>>

Obtain the raw bytes holding the checksum.

source

pub fn digest_table_of_contents_with( &mut self, checksum: ChecksumType ) -> XarResult<Vec<u8>>

Digest the table of contents content with the specified algorithm.

source

pub fn files(&self) -> XarResult<Vec<(String, File)>>

Obtain the file entries in this archive.

source

pub fn find_file(&self, filename: &str) -> XarResult<Option<File>>

Attempt to find the File entry for a given path in the archive.

source

pub fn write_file_data_heap_from_file( &mut self, file: &File, writer: &mut impl Write ) -> XarResult<usize>

Write heap file data for a given file record to a writer.

This will write the raw data backing a file as stored in the heap. There’s a good chance the raw data is encoded/compressed.

Returns the number of bytes written.

source

pub fn write_file_data_heap_from_id( &mut self, id: u64, writer: &mut impl Write ) -> XarResult<usize>

Write heap file data for a given file ID to a writer.

This is a wrapper around Self::write_file_data_heap_from_file that resolves the File given a file ID.

source

pub fn write_file_data_decoded_from_file( &mut self, file: &File, writer: &mut impl Write ) -> XarResult<usize>

Write decoded file data for a given file record to a writer.

This will call Self::write_file_data_heap_from_file and will decode that data stream, if the file data is encoded.

source

pub fn write_file_data_decoded_from_id( &mut self, id: u64, writer: &mut impl Write ) -> XarResult<usize>

Write decoded file data for a given file ID to a writer.

This is a wrapper for Self::write_file_data_decoded_from_file that locates the File entry given a file ID.

source

pub fn get_file_data_from_path( &mut self, path: &str ) -> XarResult<Option<Vec<u8>>>

Resolve data for a given path.

source

pub fn unpack(&mut self, dest_dir: impl AsRef<Path>) -> XarResult<()>

Unpack the contents of the XAR archive to a given directory.

source

pub fn checksum(&mut self) -> XarResult<(ChecksumType, Vec<u8>)>

Obtain the archive checksum.

The checksum consists of a digest format and a raw digest.

source

pub fn verify_table_of_contents_checksum(&mut self) -> XarResult<bool>

Validate the recorded checksum of the table of contents matches actual file state.

Will Err if an error occurs obtaining or computing the checksums. Returns Ok with a bool indicating if the checksums matched.

source

pub fn rsa_signature( &mut self ) -> XarResult<Option<(Vec<u8>, Vec<CapturedX509Certificate>)>>

Obtain RSA signature data from this archive.

The returned tuple contains the raw signature data and the embedded X.509 certificates.

source

pub fn verify_rsa_checksum_signature(&mut self) -> XarResult<bool>

Verifies the RSA signature in the archive.

This verifies that the RSA signature in the archive, if present, is a valid signature for the archive’s checksum data.

The boolean return value indicates if signature validation was performed.

source

pub fn cms_signature(&mut self) -> XarResult<Option<SignedData>>

Attempt to resolve a cryptographic message syntax (CMS) signature.

The data signed by the CMS signature is the raw data returned by Self::checksum.

source

pub fn verify_cms_signature(&mut self) -> XarResult<bool>

Verifies the cryptographic message syntax (CMS) signature, if present.

Trait Implementations§

source§

impl<R: Debug + Read + Seek + Sized + Debug> Debug for XarReader<R>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> RefUnwindSafe for XarReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for XarReader<R>
where R: Send,

§

impl<R> Sync for XarReader<R>
where R: Sync,

§

impl<R> Unpin for XarReader<R>
where R: Unpin,

§

impl<R> UnwindSafe for XarReader<R>
where R: UnwindSafe,

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

§

type Output = T

Should always be Self
source§

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

§

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

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more