Skip to main content

SerializedFile

Struct SerializedFile 

Source
pub struct SerializedFile {
    pub version: u32,
    pub unity_version: String,
    pub unity: UnityVersion,
    pub target_platform: i32,
    pub big_endian: bool,
    pub types: Vec<SerializedType>,
    pub objects: Vec<ObjectInfo>,
    pub script_types: Vec<(i32, i64)>,
    pub externals: Vec<External>,
    pub ref_types: Vec<SerializedType>,
    pub user_information: String,
    /* private fields */
}
Expand description

A parsed SerializedFile: its header fields, type table, object table, script references and external files, with the file’s bytes kept so objects can be read from it.

Fields§

§version: u32

The container version (21 or 22: see VERSIONS).

§unity_version: String

The Unity version string the file was built with (2019.4.20f1).

§unity: UnityVersion§target_platform: i32

Unity’s BuildTarget number the file was built for.

§big_endian: bool

Whether the metadata and the objects’ bytes are big-endian.

§types: Vec<SerializedType>

The type table.

§objects: Vec<ObjectInfo>

The object table, in file order.

§script_types: Vec<(i32, i64)>

Script references: (file index, path id).

§externals: Vec<External>

The files this file’s pointers can name (file id = index + 1).

§ref_types: Vec<SerializedType>

The table of types of managed references ([SerializeReference]).

§user_information: String

The user string at the end of the metadata.

Implementations§

Source§

impl SerializedFile

Source

pub fn looks_like(bytes: &[u8]) -> bool

Whether bytes start like a SerializedFile of a supported version (to tell them from other files).

Source

pub fn container_version(bytes: &[u8]) -> Option<u32>

The container version of bytes when they are a SerializedFile of any version, supported or not: a supported version by its field alone (a damaged file of it is for SerializedFile::parse to refuse), another version only when the header’s own size fields agree with bytes.len(), so that other files (streamed resources, configs) are not taken for one. None for bytes that are no SerializedFile.

Source

pub fn parse(data: Vec<u8>) -> Result<Self>

Parse the SerializedFile data. The header’s sizes must match data, the object table must lie inside it and the metadata must end exactly where the header says; a version outside VERSIONS, a file with embedded type trees, a duplicate path id and every length that runs past the bytes are refused with an Error that names what was found.

Source

pub fn object(&self, path_id: i64) -> Option<&ObjectInfo>

The object with this path id, if the file has one.

Source

pub fn bytes(&self, o: &ObjectInfo) -> Result<&[u8]>

The bytes of an object of this file. o should come from this file’s own SerializedFile::objects: an ObjectInfo of another file that names bytes outside this one is an error naming the object and its range.

Source

pub fn decode_with(&self, o: &ObjectInfo, tree: &TypeTree) -> Result<Decoded>

Decode an object’s bytes from its start with tree (its class’s type tree), reporting the bytes after what the tree covers in Decoded::rest (see Decoded::covered).

Source

pub fn decode( &self, o: &ObjectInfo, package: &TypeTreePackage, ) -> Result<Decoded>

Decode an object with its class’s type tree from package. The tree must cover the object’s bytes, but for a MonoBehaviour, whose script fields follow its base fields.

Trait Implementations§

Source§

impl Clone for SerializedFile

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 SerializedFile

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

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.