Skip to main content

ValueKind

Enum ValueKind 

Source
#[repr(u32)]
pub enum ValueKind {
Show 21 variants Nil = 0, Bool = 1, Int = 2, BigInt = 3, Float = 4, Rational = 5, String = 6, List = 7, Tuple = 8, Dict = 9, Set = 10, Range = 11, StopIteration = 12, Instance = 13, Class = 14, Function = 15, Module = 16, Exception = 17, Generator = 18, Iterator = 19, Other = 20,
}
Expand description

Value kinds returned by HostApi::value_kind.

Over the FFI these travel as plain u32 - convert with as u32 / ValueKind::from_u32. The host-side mapping (and the coverage test guarding that every interpreter value maps to one of these) lives in the feature-gated plugin module in the interpreter crate.

Variants§

§

Nil = 0

The nil value.

§

Bool = 1

A boolean.

§

Int = 2

An integer that fits in an i64 (int_get succeeds).

§

BigInt = 3

An integer that does not fit in an i64 (int_get fails; use value_display/value_str).

§

Float = 4

A float.

§

Rational = 5

A rational number.

§

String = 6

A string (string_get succeeds).

§

List = 7

A list (list_len/list_get succeed).

§

Tuple = 8

A tuple.

§

Dict = 9

A dict.

§

Set = 10

A set.

§

Range = 11

A range.

§

StopIteration = 12

The StopIteration sentinel - what __next__ returns when an iterator is exhausted.

§

Instance = 13

A plain class instance (fields via attr_get/attr_set, methods via invoke_method).

§

Class = 14

A class (instantiate via call_value).

§

Function = 15

A callable function value (closure, native function, or bound method) - use call_value.

§

Module = 16

A module.

§

Exception = 17

An exception instance.

§

Generator = 18

A generator.

§

Iterator = 19

A list/tuple/range/template iterator (drive via invoke_method with __next__).

§

Other = 20

VM-internal values a plugin should never meaningfully receive.

Implementations§

Source§

impl ValueKind

Source

pub const fn from_u32(code: u32) -> Self

Decode a raw kind code from HostApi::value_kind; unknown codes map to ValueKind::Other.

Trait Implementations§

Source§

impl Clone for ValueKind

Source§

fn clone(&self) -> ValueKind

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 Copy for ValueKind

Source§

impl Debug for ValueKind

Source§

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

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

impl Eq for ValueKind

Source§

impl PartialEq for ValueKind

Source§

fn eq(&self, other: &ValueKind) -> 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 ValueKind

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> 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.