Skip to main content

ObjectRef

Struct ObjectRef 

Source
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

Source

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.

Source

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.

Source

pub fn file(&self) -> &Arc<SerializedFile> ⓘ

The file it belongs to.

Source

pub fn index(&self) -> u32

Source

pub fn info(&self) -> &ObjectInfo

Its table row, read from the file’s table (no copy).

Source

pub fn path_id(&self) -> i64

path_id.

Source

pub fn class_id(&self) -> i32

class_id.

Source

pub fn serialized_type(&self) -> Option<&SerializedType>

The type record it resolves to, if any.

Source

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).

Source

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.

Source

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.

Source

pub fn read_typetree( &self, nodes: Option<&Arc<Tree>>, check_read: bool, ) -> Result<Parsed, ParseError>

read_typetree(nodes, wrap=False, check_read).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn clear_raw_data(&self)

Restore the original save payload, marking this file and its parents. Reads continue using the original reader throughout.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for ObjectRef

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ObjectRef

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.