Skip to main content

Value

Enum Value 

Source
pub enum Value {
    Bool(bool),
    Int(i64),
    UInt(u64),
    F32(u32),
    F64(u64),
    Str(RawStr),
    Bytes(Bytes),
    Prims(PrimArray),
    List(Vec<Value>),
    Tuple(Box<[Value]>),
    Dict(Map),
}
Expand description

A value read through a typetree. Not Clone (module docs).

Variants§

§

Bool(bool)

bool (any non-zero byte is true).

§

Int(i64)

Every integer that fits i64.

§

UInt(u64)

A UInt64/FileSize value above i64::MAX.

§

F32(u32)

A float node’s bits, after crate::walk::FloatMode.

§

F64(u64)

A double node’s bits, every bit kept.

§

Str(RawStr)

A string: raw bytes, valid UTF-8 or not.

§

Bytes(Bytes)

TypelessData.

§

Prims(PrimArray)

A primitive array read as one run.

§

List(Vec<Value>)

Any other array.

§

Tuple(Box<[Value]>)

A pair (two items), or an aligned primitive array on the pure-Python path.

§

Dict(Map)

A class, PPtr, registry or ReferencedObject.

Implementations§

Source§

impl Value

Source

pub fn as_i64(&self) -> Option<i64>

The integer, if this is one (not a bool, as UnityPy’s dict keeps them apart).

Source

pub fn as_u64(&self) -> Option<u64>

The unsigned integer, if this is a non-negative integer.

Source

pub fn as_f64(&self) -> Option<f64>

The float as Python holds it (an F32 widened exactly).

Source

pub fn as_bool(&self) -> Option<bool>

The bool.

Source

pub fn as_str(&self) -> Option<&str>

The string, when it is valid UTF-8.

Source

pub fn as_bytes(&self) -> Option<&[u8]>

Raw bytes: a string’s, TypelessData’s, or a vector<UInt8>’s.

Source

pub fn as_shared_bytes(&self) -> Option<&Bytes>

The zero-copy buffer of TypelessData or a vector<UInt8>, for a hand-off to another stage without copying.

Source

pub fn as_dict(&self) -> Option<&Map>

The map, if this is a dict.

Trait Implementations§

Source§

impl Debug for Value

Source§

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

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

impl Drop for Value

Dropped without recursion and without allocating, each value looked at once, so in time linear in the values held at any depth. The values waiting are a stack of piles, each a value’s own vector of items: the innermost is taken from the end one value at a time, and a value with items of its own has them taken out (its vector moves) to become the innermost pile, the rest of the one it came from saved in a value of its own, along with the pile above that (pushed into the slot the value left free). A pile done, the one saved above it resumes. A value of any depth takes the same stack, so a read (and a failed read’s partial values) may drop on a thread of any stack size, and the heap never goes above what the values held.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for Value

Source§

impl PartialEq for Value

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 Value

Auto Trait Implementations§

§

impl !Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl !UnwindSafe for Value

§

impl Forget for Value

§

impl Move for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

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