Skip to main content

WriteError

Enum WriteError 

Source
#[non_exhaustive]
pub enum WriteError { MissingKey(RawStr), TypeMismatch { node: RawStr, expected: &'static str, }, OutOfRange { node: RawStr, }, NoRefTypes, NoRefTypesAttribute, RefTypeNotFound, Malformed(RawStr), NoTypeTree { class_id: i32, why: Option<NoTree>, }, Tree(Box<ParseError>), Limit(LimitError), Charge(ChargeError), }
Expand description

Why writing a value failed (the dump’s L3 "error"). Each variant stands for the exceptions Self::exceptions names, the classes UnityPy 1.25.2’s write_typetree raises there; a variant UnityPy has no counterpart for names none.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

MissingKey(RawStr)

A child name missing from the dict, or a ReferencedObject’s type or one of its names (KeyError).

§

TypeMismatch

A value of the wrong type for its node. expected says what the node takes, and which exception UnityPy raises: struct.error for int and float; AttributeError for a str (value.encode), an attribute, a ref type with a tree (None.m_MetaFlag) and a type that is not a dict (getattr(typ, "class")); TypeError for bytes, a sized iterable (len) and a ReferencedObject’s dict (value[...]); TypeError, KeyError or IndexError for a sequence of two (value[0] of an int, a dict or a short sequence). A modelled attribute is the writer’s own refusal of a dunder name, which UnityPy reads and may write (PARITY.md section 19.3).

Fields

§node: RawStr

The node’s name.

§expected: &'static str

What the node takes.

§

OutOfRange

An integer outside its node’s width (struct.error), or a finite float that overflows f32 (OverflowError).

Fields

§node: RawStr

The node’s name.

§

NoRefTypes

ReferencedObject data with no assets file, or an empty ref_types list (the writer raises where the reader does not; TypeTreeHelper.py:99-100): ValueError.

§

NoRefTypesAttribute

ReferencedObject data against a file with no ref_types attribute (RefTypes::Absent: a SerializedFile below format 20, which UnityPy never sets it on, files/SerializedFile.py:306-308): reading assetfile.ref_types raises AttributeError (TypeTreeHelper.py:99).

§

RefTypeNotFound

ReferencedObject data whose type is not in ref_types (ValueError).

§

Malformed(RawStr)

A malformed node the writer reached: a pair’s or an Array’s missing child (IndexError), or a matched ref type’s rows that make no tree, which UnityPy refuses when it parses the file (an IndexError too, TreeError).

§

NoTypeTree

The object has no tree to write with: UnityPy raises the same exception for a write as for a read (files/ObjectReader.py:264-307; the read side’s ParseError::NoTypeTree).

Fields

§class_id: i32

The object’s class.

§why: Option<NoTree>

Which exception, as the read side’s.

§

Tree(Box<ParseError>)

Resolving the object’s tree failed (a tree that does not compile, a provider’s failure): the writer never ran.

§

Limit(LimitError)

A bound from Limits.

§

Charge(ChargeError)

The input’s meter or the budget refused the output’s memory.

Implementations§

Source§

impl WriteError

Source

pub fn exceptions(&self) -> &'static [&'static str]

The classes, by __name__ (error is struct.error), of the exceptions UnityPy 1.25.2’s write_typetree (TypeTreeHelper.py:407-458 and streams/EndianBinaryWriter.py) raises where the writer reports this error, as the variants’ docs give them; tests/walk_fixtures.rs checks against this every raise in the cases, the value cases and W2’s matrix tools/fixtures/walk.py records. None for an error UnityPy has no counterpart for: a bound of Limits or a refused charge (PARITY.md section 19.3), a dunder attribute (Self::TypeMismatch), and a tree that failed before the writer ran (Self::Tree: the read side’s error); a Self::NoTypeTree with no why says nothing of UnityPy’s.

Trait Implementations§

Source§

impl Clone for WriteError

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 WriteError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for WriteError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for WriteError

Source§

impl Error for WriteError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Replaced by Error::source.
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<WriteError> for SaveError

Source§

fn from(source: WriteError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for WriteError

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for WriteError

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.