pub struct SerializedFile { /* private fields */ }Expand description
A parsed SerializedFile: metadata and object table. Values are read on
demand through ObjectRef.
Implementations§
Source§impl SerializedFile
impl SerializedFile
Sourcepub fn get_writeable_cab(
&self,
name: Option<&RawStr>,
) -> Result<Option<WriteableCab>, SaveError>
pub fn get_writeable_cab( &self, name: Option<&RawStr>, ) -> Result<Option<WriteableCab>, SaveError>
Create a resource in the parent bundle/WebFile and append its external.
Top-level SerializedFiles have no writable CAB, as in UnityPy.
Sourcepub fn get_writeable_cab_with_guid(
&self,
name: Option<&RawStr>,
guid: [u8; 16],
) -> Result<Option<WriteableCab>, SaveError>
pub fn get_writeable_cab_with_guid( &self, name: Option<&RawStr>, guid: [u8; 16], ) -> Result<Option<WriteableCab>, SaveError>
The same operation with the last sixteen ASCII bytes of a UUID URN
supplied by the caller (the Python binding can pass uuid.uuid1()).
This also makes the otherwise nondeterministic GUID replayable.
Sourcepub fn writeable_externals(&self) -> Result<MeteredVec<External>, SaveError>
pub fn writeable_externals(&self) -> Result<MeteredVec<External>, SaveError>
Pending metadata additions. Loaded metadata remains the immutable
externals() view, as original object bytes do after set_raw_data.
Source§impl SerializedFile
impl SerializedFile
Sourcepub fn is_changed(&self) -> bool
pub fn is_changed(&self) -> bool
Whether explicitly marked or an object replacement has been installed.
Sourcepub fn mark_changed(&self)
pub fn mark_changed(&self)
Mark this file and all live parent containers changed.
Source§impl SerializedFile
impl SerializedFile
Sourcepub fn parse(
name: RawStr,
data: Bytes,
parent: Option<Parent>,
meter: &Arc<Meter>,
ctx: &Arc<FileContext>,
) -> Result<Arc<Self>, Error>
pub fn parse( name: RawStr, data: Bytes, parent: Option<Parent>, meter: &Arc<Meter>, ctx: &Arc<FileContext>, ) -> Result<Arc<Self>, Error>
SerializedFile.__init__ over bytes (the memory reader’s rules).
Everything it keeps is charged to meter, the input’s.
Sourcepub fn parse_with_reader(
name: RawStr,
data: Bytes,
parent: Option<Parent>,
meter: &Arc<Meter>,
ctx: &Arc<FileContext>,
reader: ReaderKind,
) -> Result<Arc<Self>, Error>
pub fn parse_with_reader( name: RawStr, data: Bytes, parent: Option<Parent>, meter: &Arc<Meter>, ctx: &Arc<FileContext>, reader: ReaderKind, ) -> Result<Arc<Self>, Error>
Self::parse by the rules of the reader UnityPy would read data
with (ReaderKind::Stream for a top-level file loaded from a path),
which its objects’ reads follow too.
Source§impl SerializedFile
impl SerializedFile
Sourcepub fn save(&self, options: SaveOptions) -> Result<Bytes, SaveError>
pub fn save(&self, options: SaveOptions) -> Result<Bytes, SaveError>
Save metadata and objects, sorting by signed path id and padding every
data block to eight bytes. The result owns its meter charge. Saving
never clears is_changed or rewrites the loaded reader’s metadata.
Old trees, required pre-v13 trees, and pre-v9’s data offset are
corrected under both layouts (Tier C writing). Otherwise UnityPy
matches UnityPy 1.25.2’s uncompressed save through format 22 and
HEAD 417d595 for formats 23-26. HEAD’s absent per-type node assertion
and formats above 26 refuse before building or charging output.
Semantic refuses with a Range collision an output that detection
would not reload as a SerializedFile (a bundle signature or gzip magic
in the header’s sizes, the brotli marker at 0x20 in metadata or object
bytes below format 22); the UnityPy layout writes it unchecked.
Sourcepub fn save_with_snapshot(
&self,
options: SaveOptions,
snapshot: &SerializedSaveSnapshot<'_>,
) -> Result<Bytes, SaveError>
pub fn save_with_snapshot( &self, options: SaveOptions, snapshot: &SerializedSaveSnapshot<'_>, ) -> Result<Bytes, SaveError>
Serialize a metered snapshot without modifying the loaded file or edits.
Source§impl SerializedFile
impl SerializedFile
Sourcepub fn occurrence_key(&self) -> (usize, &[usize])
pub fn occurrence_key(&self) -> (usize, &[usize])
The identity of this file occurrence while it is held. A dependency keeps the same input address and directory path across cache reopens.
Sourcepub fn meter(&self) -> &Arc<Meter> ⓘ
pub fn meter(&self) -> &Arc<Meter> ⓘ
The meter of the input it belongs to: what reading its objects
charges (crate::walk::ReadCtx::meter).
Sourcepub fn pinned(&self) -> u64
pub fn pinned(&self) -> u64
The length of the buffer its bytes are a slice of, which a slice of
them keeps alive: its container’s decoded run, or the container’s
own bytes’ buffer (Parent::pinned); its own length for a
top-level file. A value read from it, and each typetree it parsed,
copy their slices out when they would keep much more than
themselves alive (crate::pin).
Sourcepub fn copies(&self) -> Copies
pub fn copies(&self) -> Copies
What its object reads and its parse copied out of the buffer its
bytes are a slice of so far (crate::pin; plan section 8, R3).
Sourcepub fn constructor_position(&self) -> i128
pub fn constructor_position(&self) -> i128
Final metadata cursor of the constructor’s input reader.
Sourcepub fn reader_kind(&self) -> ReaderKind
pub fn reader_kind(&self) -> ReaderKind
The reader used for metadata and object reads: stream for paths,
otherwise memory (ObjectRef::read_typetree, ObjectRef::raw_data).
Sourcepub fn reader_position(&self) -> i128
pub fn reader_position(&self) -> i128
The shared reader’s position after loading metadata and the eager container.
Sourcepub fn header(&self) -> &SerializedHeader
pub fn header(&self) -> &SerializedHeader
The header.
Sourcepub fn unity_version(&self) -> Option<&RawStr>
pub fn unity_version(&self) -> Option<&RawStr>
The version string as read (format 7 and up).
Sourcepub fn version(&self) -> Option<&ResolvedVersion>
pub fn version(&self) -> Option<&ResolvedVersion>
Chain 2’s result (format 7 and up).
Sourcepub fn target_platform(&self) -> Option<i32>
pub fn target_platform(&self) -> Option<i32>
The raw target platform (format 8 and up).
Sourcepub fn enable_type_tree(&self) -> bool
pub fn enable_type_tree(&self) -> bool
Whether type records carry trees.
Sourcepub fn big_id_enabled(&self) -> i32
pub fn big_id_enabled(&self) -> i32
big_id_enabled (formats 7-13, else 0).
Sourcepub fn types(&self) -> &[SerializedType]
pub fn types(&self) -> &[SerializedType]
Type records, in file order, script indexes written back.
Sourcepub fn ref_types(&self) -> Option<&[SerializedType]>
pub fn ref_types(&self) -> Option<&[SerializedType]>
Ref types (format 20 and up).
Sourcepub fn ref_types_view(&self) -> RefTypes<'_>
pub fn ref_types_view(&self) -> RefTypes<'_>
The reader’s view of the ref types.
Sourcepub fn script_types(&self) -> &[ScriptRef]
pub fn script_types(&self) -> &[ScriptRef]
Script type references.
Sourcepub fn user_information(&self) -> Option<&RawStr>
pub fn user_information(&self) -> Option<&RawStr>
userInformation (format 5 and up).
Sourcepub fn object_infos(&self) -> &[ObjectInfo]
pub fn object_infos(&self) -> &[ObjectInfo]
The object table in file order, repeated path ids kept.
Sourcepub fn object_order(&self) -> &[u32]
pub fn object_order(&self) -> &[u32]
UnityPy’s objects dict order: indexes into Self::object_infos of
each path id’s last entry, at its first position.
Sourcepub fn objects(self: &Arc<Self>) -> impl Iterator<Item = ObjectRef> + '_
pub fn objects(self: &Arc<Self>) -> impl Iterator<Item = ObjectRef> + '_
The objects, in dict order.
Sourcepub fn objects_by_path(self: &Arc<Self>) -> impl Iterator<Item = ObjectRef> + '_
pub fn objects_by_path(self: &Arc<Self>) -> impl Iterator<Item = ObjectRef> + '_
The objects in ascending signed path id (UnityPy’s
sorted(objects.values(), key=lambda o: o.path_id)): the table
Self::object searches, kept and charged with the file, so a
caller orders them without a copy or a sort.
Sourcepub fn object(self: &Arc<Self>, path_id: i64) -> Option<ObjectRef>
pub fn object(self: &Arc<Self>, path_id: i64) -> Option<ObjectRef>
The object objects[path_id] holds.
Sourcepub fn container(self: &Arc<Self>) -> Result<&Container, Error>
pub fn container(self: &Arc<Self>) -> Result<&Container, Error>
The container rows of the first AssetBundle in dict order, read once
(crate::container::read_container) and published
(get_or_publish_result: the read runs outside the cell, and a
refused charge is returned, not kept). What the read was granted and
its container does not keep is the open’s work (module docs, “Work”).
Sourcepub fn context(&self) -> &Arc<FileContext> ⓘ
pub fn context(&self) -> &Arc<FileContext> ⓘ
The context it was loaded with.