Skip to main content

Bundle

Struct Bundle 

Source
pub struct Bundle { /* private fields */ }
Expand description

An open UnityFS bundle: its header, blocks and nodes, with the file kept open to read nodes by range.

Implementations§

Source§

impl Bundle

Source

pub fn open(path: &Path) -> Result<Self>

Open the bundle at path: read its header and block table and check that the sizes add up (the header’s size is the file’s, the blocks end where the file does, every node lies in the blocks’ bytes). Reads nothing of the data.

Source

pub fn from_source(path: &Path, source: Box<dyn BundleSource>) -> Result<Self>

As Bundle::open, on any seekable source (path only names it in errors).

Source

pub fn path(&self) -> &Path

The file the bundle was opened from.

Source

pub fn header(&self) -> &BundleHeader

The header as stored.

Source

pub fn hash(&self) -> [u8; 16]

The 16 bytes at the start of the block table (nothing reads them).

Source

pub fn nodes(&self) -> &[BundleNode]

The files in the bundle, in the order the directory lists them.

Source

pub fn node(&self, path: &str) -> Option<&BundleNode>

The node whose path is exactly path.

Source

pub fn blocks(&self) -> impl ExactSizeIterator<Item = Block> + '_

The blocks, in data order.

Source

pub fn data_len(&self) -> u64

The size of all blocks once decompressed.

Source

pub fn read( &self, node: &BundleNode, offset: u64, len: usize, ) -> Result<Vec<u8>>

len bytes of node, from offset bytes into it. Only the blocks the range touches are decompressed. A range outside the node is an error.

Source

pub fn read_node(&self, node: &BundleNode) -> Result<Vec<u8>>

All of node’s bytes. Blocks are decompressed one after the other and not kept.

Trait Implementations§

Source§

impl Debug for Bundle

Source§

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

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.