pub struct ObjectRef { /* private fields */ }Expand description
One object of a SerializedFile: the file and the index of its row
(module docs).
Implementations§
Source§impl ObjectRef
impl ObjectRef
Sourcepub fn parse_monobehaviour_head(
&self,
nodes: Option<&Arc<Tree>>,
) -> Result<Parsed, ParseError>
pub fn parse_monobehaviour_head( &self, nodes: Option<&Arc<Tree>>, ) -> Result<Parsed, ParseError>
Read only the MonoBehaviour head, ignoring trailing script fields
(files/ObjectReader.py:325-330). With no override, request class 114
from the providers, even when the object stores an embedded tree.
Sourcepub fn new(file: Arc<SerializedFile>, index: u32) -> Option<Self>
pub fn new(file: Arc<SerializedFile>, index: u32) -> Option<Self>
The object at index in SerializedFile::object_infos, or None
past the table’s end.
Sourcepub fn file(&self) -> &Arc<SerializedFile> ⓘ
pub fn file(&self) -> &Arc<SerializedFile> ⓘ
The file it belongs to.
Sourcepub fn index(&self) -> u32
pub fn index(&self) -> u32
Its index in SerializedFile::object_infos.
Sourcepub fn info(&self) -> &ObjectInfo
pub fn info(&self) -> &ObjectInfo
Its table row, read from the file’s table (no copy).
Sourcepub fn serialized_type(&self) -> Option<&SerializedType>
pub fn serialized_type(&self) -> Option<&SerializedType>
The type record it resolves to, if any.
Sourcepub fn raw_data(&self) -> Result<Bytes, Error>
pub fn raw_data(&self) -> Result<Bytes, Error>
get_raw_data: byte_size bytes from byte_start, cut short at the
end of the file (a slice of the file’s buffer, no copy, so it keeps
that whole buffer alive while it lives: a bundle entry’s run, unlike
Self::read_typetree’s value, which crate::pin copies out of a
much larger run), by the file’s reader’s rules
(SerializedFile::reader_kind): the stream
reader (a file loaded from a path) refuses a negative byte_start, or
one at or above 2^63, as UnityPy’s does on every machine, where the
memory reader slices from the end or reads nothing. A byte_start
past the largest file the file system takes is UnityPy’s OSError
on that machine; the stream reader takes it and reads nothing
(crate::stream::ReaderKind, PARITY.md section 19.3).
Sourcepub fn tree(
&self,
nodes: Option<&Arc<Tree>>,
) -> Result<Option<TreeRef>, ParseError>
pub fn tree( &self, nodes: Option<&Arc<Tree>>, ) -> Result<Option<TreeRef>, ParseError>
The tree a read would use: nodes when given, else the type record’s,
else the provider chain’s class tree (ObjectReader.py:285-307), with
no script (TreeRequest::script is None). Ok(None) where UnityPy
raises: Self::why_no_tree says which exception. The
MonoBehaviour script hook needs the Environment to dereference
m_Script: crate::env::Environment::object_tree.
Sourcepub fn why_no_tree(&self) -> Option<NoTree>
pub fn why_no_tree(&self) -> Option<NoTree>
Why Self::tree finds none for this object without nodes (its
type record holds none, and no provider has its class’s): the
exception UnityPy raises there (NoTree,
ProviderChain::why_none for the file’s version, or for none below
format 7). None where no provider says. What
ParseError::NoTypeTree and WriteError::NoTypeTree carry.
Sourcepub fn read_typetree(
&self,
nodes: Option<&Arc<Tree>>,
check_read: bool,
) -> Result<Parsed, ParseError>
pub fn read_typetree( &self, nodes: Option<&Arc<Tree>>, check_read: bool, ) -> Result<Parsed, ParseError>
read_typetree(nodes, wrap=False, check_read).
Sourcepub fn read_typetree_lossless(
&self,
nodes: Option<&Arc<Tree>>,
check_read: bool,
meter: &Arc<Meter>,
) -> Result<Parsed, ParseError>
pub fn read_typetree_lossless( &self, nodes: Option<&Arc<Tree>>, check_read: bool, meter: &Arc<Meter>, ) -> Result<Parsed, ParseError>
Read the dictionary on the supplied meter with exact serialized float bits, including signalling NaNs used by some animation slots. Tree resolution stays scoped to the owning file.
Sourcepub fn read_typetree_object(
&self,
nodes: Option<&Arc<Tree>>,
check_read: bool,
) -> Result<Parsed, ParseError>
pub fn read_typetree_object( &self, nodes: Option<&Arc<Tree>>, check_read: bool, ) -> Result<Parsed, ParseError>
Read object-mode values into the dict model, retaining the Python reader’s pointer and referenced-type validation. The binding constructs Python classes from these values; the core fallback also uses this mode.
Sourcepub fn read_object_fields(&self) -> Result<(Parsed, FieldProgress), ParseError>
pub fn read_object_fields(&self) -> Result<(Parsed, FieldProgress), ParseError>
Read each child’s node and value without collapsing duplicate names. A later reader error is returned with the completed construction prefix.
Sourcepub fn read_object_fields_with_nodes(
&self,
nodes: Option<&Arc<Tree>>,
) -> Result<(Parsed, FieldProgress), ParseError>
pub fn read_object_fields_with_nodes( &self, nodes: Option<&Arc<Tree>>, ) -> Result<(Parsed, FieldProgress), ParseError>
Read object fields using an explicit tree before the file’s own tree.
Sourcepub fn compiled_tree(&self) -> Option<&Arc<Tree>>
pub fn compiled_tree(&self) -> Option<&Arc<Tree>>
The type record’s own tree once it is compiled (the tree
Self::tree resolves with no nodes for an object whose record
stores one), without compiling or waiting: None until a read has
compiled it, or when the record has none.
Sourcepub fn emit_typetree<S: Sink>(
&self,
tree: &Tree,
check_read: bool,
sink: &mut S,
extra_work: impl FnOnce(&S) -> u64,
) -> Option<(S::Obj, i64)>
pub fn emit_typetree<S: Sink>( &self, tree: &Tree, check_read: bool, sink: &mut S, extra_work: impl FnOnce(&S) -> u64, ) -> Option<(S::Obj, i64)>
Self::read_typetree with tree as nodes, its values handed to
sink as they are read (crate::walk::emit), and the bytes read;
or None where the direct read gives up, and the full read is to be
made instead. Only an object of byte_size > 0 (UnityPyBoost’s
reader) is read; a check_read mismatch gives up too. The read’s
work, and extra_work of the caller’s, are counted on the file’s
meter in one check-and-add once the values are made; work the
allowance cannot hold gives up, counting nothing, and the read stops
as soon as its own work passes what the allowance holds. Copies none
of the file’s bytes out (crate::pin): the sink’s values are its
own.
Sourcepub fn emit_typetree_uncounted<S: Sink>(
&self,
tree: &Tree,
check_read: bool,
sink: &mut S,
max_work: u64,
) -> Result<(S::Obj, i64, u64), u64>
pub fn emit_typetree_uncounted<S: Sink>( &self, tree: &Tree, check_read: bool, sink: &mut S, max_work: u64, ) -> Result<(S::Obj, i64, u64), u64>
Self::emit_typetree’s read, its work (at most max_work, or it
gives up) returned, not counted: the caller counts it. A read that
gives up returns the work it did (Err), for the caller to count.
Sourcepub fn parse_as_dict(&self, check_read: bool) -> Result<Parsed, ParseError>
pub fn parse_as_dict(&self, check_read: bool) -> Result<Parsed, ParseError>
parse_as_dict(check_read=check_read): Self::read_typetree with
the resolved tree.
Sourcepub fn set_raw_data(&self, data: impl AsRef<[u8]>) -> Result<(), SaveError>
pub fn set_raw_data(&self, data: impl AsRef<[u8]>) -> Result<(), SaveError>
Replace the bytes file save will write, and mark every parent changed. Reads continue using the original reader, as UnityPy does.
Sourcepub fn clear_raw_data(&self)
pub fn clear_raw_data(&self)
Restore the original save payload, marking this file and its parents. Reads continue using the original reader throughout.
Sourcepub fn save_typetree(
&self,
value: &Parsed,
nodes: Option<&Arc<Tree>>,
rules: WriteRules,
) -> Result<Bytes, SaveError>
pub fn save_typetree( &self, value: &Parsed, nodes: Option<&Arc<Tree>>, rules: WriteRules, ) -> Result<Bytes, SaveError>
Write and install a typetree, as files/ObjectReader.py:264-276 does.
A failed write or replacement leaves the file’s previous edit intact.
Sourcepub fn write_typetree(
&self,
value: &Parsed,
nodes: Option<&Arc<Tree>>,
rules: WriteRules,
) -> Result<Bytes, WriteError>
pub fn write_typetree( &self, value: &Parsed, nodes: Option<&Arc<Tree>>, rules: WriteRules, ) -> Result<Bytes, WriteError>
save_typetree’s bytes: UnityPy’s writer (or rules) over value,
written into a buffer charged to the file’s input meter, whose charge
rides in the returned Bytes.