apple_xar::reader

Struct 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> Freeze for XarReader<R>
where R: Freeze,

§

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.

Source§

impl<T> Instrument for T

Source§

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

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

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

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

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T