pub struct BundleFile { /* private fields */ }Expand description
A bundle: header and directory parsed, data decoded on demand.
Implementations§
Source§impl BundleFile
impl BundleFile
Sourcepub fn open(
name: RawStr,
data: Bytes,
parent: Option<Parent>,
meter: &Arc<Meter>,
ctx: &Arc<FileContext>,
) -> Result<Arc<Self>, Error>
pub fn open( name: RawStr, data: Bytes, parent: Option<Parent>, meter: &Arc<Meter>, ctx: &Arc<FileContext>, ) -> Result<Arc<Self>, Error>
Reads the header, blocks-info and directory of bytes (the memory
reader’s rules). Decodes no data block. Everything it keeps is
charged to meter, the input’s.
Sourcepub fn open_with_reader(
name: RawStr,
data: Bytes,
parent: Option<Parent>,
meter: &Arc<Meter>,
ctx: &Arc<FileContext>,
reader: ReaderKind,
) -> Result<Arc<Self>, Error>
pub fn open_with_reader( name: RawStr, data: Bytes, parent: Option<Parent>, meter: &Arc<Meter>, ctx: &Arc<FileContext>, reader: ReaderKind, ) -> Result<Arc<Self>, Error>
Self::open by the rules of the reader UnityPy would read data
with (ReaderKind::Stream for a top-level file loaded from a path):
the header, the blocks-info section and the blocks’ stored bytes are
read through it; the blocks-info table and the entries are memory
(UnityPy decodes them into bytes, files/BundleFile.py:141-142, :173-186).
Source§impl BundleFile
impl BundleFile
Sourcepub fn save(&self, options: BundleSaveOptions) -> Result<Bytes, SaveError>
pub fn save(&self, options: BundleSaveOptions) -> Result<Bytes, SaveError>
Rebuild the bundle from its live ordered files dictionary.
Repeated names collapse to their final row at the first position.
Saving retains change flags and leaves the original input intact.
None provides canonical idempotence. Original adopts the first
loaded block’s codec, so a stored first chunk can change the next
Original save’s block layout, as in UnityPy.
Format 9 and named HC follow HEAD 417d595. Earlier formats retain 1.25.2’s other packers. Formats above 9 refuse before output charges. Legacy signatures ignore the packer, as UnityPy does.
Sourcepub fn save_with_entries(
&self,
options: BundleSaveOptions,
entries: &[(RawStr, u32, Bytes)],
) -> Result<Bytes, SaveError>
pub fn save_with_entries( &self, options: BundleSaveOptions, entries: &[(RawStr, u32, Bytes)], ) -> Result<Bytes, SaveError>
Save an ordered caller-supplied directory of already serialized children. The caller owns and meters the names and payload snapshots.
Sourcepub fn save_with_snapshot(
&self,
options: BundleSaveOptions,
entries: &[(RawStr, u32, Bytes)],
header: &BundleHeader,
block_flags: u16,
mode: Option<(u32, u16)>,
) -> Result<Bytes, SaveError>
pub fn save_with_snapshot( &self, options: BundleSaveOptions, entries: &[(RawStr, u32, Bytes)], header: &BundleHeader, block_flags: u16, mode: Option<(u32, u16)>, ) -> Result<Bytes, SaveError>
Save charged caller-owned directory and header snapshots. mode selects
the FS/legacy body API; None dispatches from the supplied signature.
Sourcepub fn save_fs(
&self,
data_flag: u32,
block_info_flag: u16,
options: SaveOptions,
) -> Result<Bytes, SaveError>
pub fn save_fs( &self, data_flag: u32, block_info_flag: u16, options: SaveOptions, ) -> Result<Bytes, SaveError>
Save the FS layout, with header/blocks-info flags first and data block flags second. Encryption is removed, never emitted: exactly the encryption mask’s bits and each block’s 0x100 bit are cleared. This Tier C correction applies in both layout modes.
Source§impl BundleFile
impl BundleFile
Sourcepub fn save_web_raw(&self, options: SaveOptions) -> Result<Bytes, SaveError>
pub fn save_web_raw(&self, options: SaveOptions) -> Result<Bytes, SaveError>
Save UnityRaw or UnityWeb’s legacy layout, with one level and a
directory padded to four bytes. UnityWeb uses a size-prefixed raw
LZMA1 stream. Format 6 belongs to save_fs instead.
Sourcepub fn save_web_raw_with_entries(
&self,
options: SaveOptions,
entries: &[(RawStr, u32, Bytes)],
) -> Result<Bytes, SaveError>
pub fn save_web_raw_with_entries( &self, options: SaveOptions, entries: &[(RawStr, u32, Bytes)], ) -> Result<Bytes, SaveError>
Save legacy layout using caller-owned, metered serialized child snapshots.
Sourcepub fn save_web_raw_with_snapshot(
&self,
options: SaveOptions,
entries: &[(RawStr, u32, Bytes)],
header: &BundleHeader,
) -> Result<Bytes, SaveError>
pub fn save_web_raw_with_snapshot( &self, options: SaveOptions, entries: &[(RawStr, u32, Bytes)], header: &BundleHeader, ) -> Result<Bytes, SaveError>
Save a charged legacy directory and current caller-owned header.
Source§impl BundleFile
impl BundleFile
Sourcepub fn constructor_position(&self) -> i128
pub fn constructor_position(&self) -> i128
Final cursor of the constructor’s outer input reader.
Sourcepub fn meter(&self) -> &Arc<Meter> ⓘ
pub fn meter(&self) -> &Arc<Meter> ⓘ
The meter of the input it belongs to (of this open of it); its entries, nested bundles included, charge it too.
Sourcepub fn source(&self) -> &Bytes
pub fn source(&self) -> &Bytes
The input bytes it was opened on (for telling two handles on one
input apart from two inputs: a resource read through from’s own
handle, plan section 3.13).
Sourcepub fn header(&self) -> &BundleHeader
pub fn header(&self) -> &BundleHeader
The header.
Sourcepub fn files(&self) -> &[FileSlot]
pub fn files(&self) -> &[FileSlot]
Loaded files dict, in order. Newly created resource writers are in
Self::writeable_cabs and follow these entries when saved.
Sourcepub fn context(&self) -> &Arc<FileContext> ⓘ
pub fn context(&self) -> &Arc<FileContext> ⓘ
The context it was opened with.
Sourcepub fn uncompressed_size(&self) -> u64
pub fn uncompressed_size(&self) -> u64
The sum of the blocks’ declared decoded sizes: what a full decode is expected to cost. The actual total can differ (module docs).
Sourcepub fn counts(&self) -> BundleCounts
pub fn counts(&self) -> BundleCounts
What this bundle’s block reads have decoded, dropped, decoded again
and cached so far (BundleCounts; a nested bundle counts its own):
what plan section 8’s R2 and R3 measure. Takes the run index’s lock
for the runs’ share.
Sourcepub fn entry_bytes(&self, dir_index: usize) -> Result<Bytes, Error>
pub fn entry_bytes(&self, dir_index: usize) -> Result<Bytes, Error>
Directory entry dir_index’s bytes: the Python slice
data[offset : offset + size] of the joined data (size -1 to the end,
negative indexes from the end, short at the end). Measures every block
before the slice first (module docs).
Sourcepub fn pinned(&self) -> u64
pub fn pinned(&self) -> u64
The length of the buffer this bundle’s own bytes are a slice of,
which a slice of a stored block keeps alive (Parent::pinned; its
own length for a top-level bundle).
Sourcepub fn entry_range(
&self,
dir_index: usize,
range: Range<u64>,
) -> Result<Bytes, Error>
pub fn entry_range( &self, dir_index: usize, range: Range<u64>, ) -> Result<Bytes, Error>
A byte range of an entry (a .resS read), short at the end of the
entry as a Python slice. It measures every block before the range as
any read does, slices a cached run that covers the range’s blocks, and
otherwise decodes those blocks into a run it caches, so later ranges
in the same blocks are slices of it.
Sourcepub fn entry(&self, dir_index: usize) -> Result<File, Error>
pub fn entry(&self, dir_index: usize) -> Result<File, Error>
Directory entry dir_index, detected and parsed (parse_file) and
published once (crate::once::get_or_publish_result); under
contention two callers may both parse it, and the loser’s result (and
its charge) is dropped. A parse the meter or the budget refuses is
returned and not kept.
Sourcepub fn load_all(&self) -> Result<(), Error>
pub fn load_all(&self) -> Result<(), Error>
UnityPy’s eager load (File.read_files, File.py:76-90): every block
decoded, every directory entry parsed in order (a path repeated in the
directory included: its earlier entry can fail the bundle though the
files dict keeps the later one); the first failure fails the bundle.
Source§impl BundleFile
impl BundleFile
Sourcepub fn get_writeable_cab(
&self,
name: Option<&RawStr>,
) -> Result<WriteableCab, SaveError>
pub fn get_writeable_cab( &self, name: Option<&RawStr>, ) -> Result<WriteableCab, SaveError>
Create or reuse a resource writer. Existing reader keys refuse. Creation alone neither marks changed nor registers an environment CAB.
Sourcepub fn writeable_cabs(&self) -> Result<MeteredVec<WriteableCab>, SaveError>
pub fn writeable_cabs(&self) -> Result<MeteredVec<WriteableCab>, SaveError>
The writers added after the loaded files, in dictionary order.
Source§impl BundleFile
impl BundleFile
Sourcepub fn mark_changed(&self)
pub fn mark_changed(&self)
Mark this container and all its live parent containers changed.
Sourcepub fn is_changed(&self) -> bool
pub fn is_changed(&self) -> bool
Whether this container or one of its children was marked changed.