Enum Value

Source
pub enum Value {
Show 16 variants Invalid, Nil, Bool(bool), Number(f64), String(RcStr), List(Rc<List>), Set(Rc<Set>), Map(Rc<Map>), Table(Rc<Table>), Function(Rc<Function>), NativeFunction(Rc<NativeFunction>), Generator(Rc<RefCell<Generator>>), NativeGenerator(Rc<RefCell<NativeGenerator>>), Class(Rc<Class>), Module(Rc<Module>), Handle(Rc<HandleData>),
}

Variants§

§

Invalid

§

Nil

§

Bool(bool)

§

Number(f64)

§

String(RcStr)

§

List(Rc<List>)

§

Set(Rc<Set>)

§

Map(Rc<Map>)

§

Table(Rc<Table>)

§

Function(Rc<Function>)

§

NativeFunction(Rc<NativeFunction>)

§

Generator(Rc<RefCell<Generator>>)

§

NativeGenerator(Rc<RefCell<NativeGenerator>>)

§

Class(Rc<Class>)

§

Module(Rc<Module>)

§

Handle(Rc<HandleData>)

Implementations§

Source§

impl Value

Source

pub fn f64(&self) -> Result<f64, Error>

Source

pub fn f32(&self) -> Result<f32, Error>

Source

pub fn usize(&self) -> Result<usize, Error>

Source

pub fn u64(&self) -> Result<u64, Error>

Source

pub fn u32(&self) -> Result<u32, Error>

Source

pub fn u16(&self) -> Result<u16, Error>

Source

pub fn u8(&self) -> Result<u8, Error>

Source

pub fn isize(&self) -> Result<isize, Error>

Source

pub fn i64(&self) -> Result<i64, Error>

Source

pub fn i32(&self) -> Result<i32, Error>

Source

pub fn i16(&self) -> Result<i16, Error>

Source

pub fn i8(&self) -> Result<i8, Error>

Source§

impl Value

Source

pub fn format_string(fmt: &str, args: Vec<Value>) -> Result<String, Error>

Source§

impl Value

Methods for dealing with unpacking values in other values

the easy_* variants are those where a Globals context is not used, but can only unpack List, Set and Map values.

Some of these methods are kind of redundant with many of the TryFrom forms. Some of these redundant unpack methods may be removed in the future.

Source

pub fn unpack_into_set( self, globals: &mut Globals, ) -> Result<IndexSet<Key>, Error>

Source

pub fn unpack_into_map( self, globals: &mut Globals, ) -> Result<IndexMap<Key, Value>, Error>

Source

pub fn unpack(self, globals: &mut Globals) -> Result<Vec<Value>, Error>

Source

pub fn unpack_into<C, T, E>(self, globals: &mut Globals) -> Result<C, Error>
where C: FromIterator<T>, T: TryFrom<Value, Error = E>, Error: From<E>,

Source

pub fn easy_unpack(self) -> Result<Vec<Value>, Error>

Source

pub fn easy_unpack2(self) -> Result<[Value; 2], Error>

Source

pub fn easy_unpack3(self) -> Result<[Value; 3], Error>

Source

pub fn easy_unpack4(self) -> Result<[Value; 4], Error>

Source

pub fn unpack_keyval(self, globals: &mut Globals) -> Result<(Key, Value), Error>

Source

pub fn unpack2(self, globals: &mut Globals) -> Result<[Value; 2], Error>

Source

pub fn unpack3(self, globals: &mut Globals) -> Result<[Value; 3], Error>

Source

pub fn unpack4(self, globals: &mut Globals) -> Result<[Value; 4], Error>

Source§

impl Value

Source

pub fn easy_iter_unpack<F, R>(&self, f: F) -> Result<R, Error>
where F: FnOnce(EasyIterUnpack<'_>) -> Result<R, Error>,

Source§

impl Value

Source

pub fn convert<T>(self, globals: &mut Globals) -> Result<T, Error>
where T: Any + ConvertValue + Clone,

For converting to a native value into a value of the desired type. If the current value is a handle of the given type, it will either unwrap or clone it. If not, it will try to convert it with the ConvertValue trait

Source

pub fn to_xref<T>(&self, globals: &mut Globals) -> Result<XRef<'_, T>, Error>
where T: Any + ConvertValue,

Source

pub fn to_xref_mut<T>( &self, globals: &mut Globals, ) -> Result<XRefMut<'_, T>, Error>
where T: Any + ConvertValue,

Source§

impl Value

Source

pub fn truthy(&self) -> bool

Source

pub fn debug_typename(&self) -> RcStr

Source

pub fn is(&self, other: &Value) -> bool

Source

pub fn lt(&self, other: &Value) -> Result<bool, Error>

Source

pub fn is_nil(&self) -> bool

Source

pub fn bool(&self) -> Result<bool, Error>

Source

pub fn number(&self) -> Result<f64, Error>

Source

pub fn string(&self) -> Result<&RcStr, Error>

Source

pub fn into_string(self) -> Result<RcStr, Error>

Source

pub fn list(&self) -> Result<&Rc<List>, Error>

Source

pub fn into_list(self) -> Result<Rc<List>, Error>

Source

pub fn set(&self) -> Result<&Rc<Set>, Error>

Source

pub fn into_set(self) -> Result<Rc<Set>, Error>

Source

pub fn map(&self) -> Result<&Rc<Map>, Error>

Source

pub fn into_map(self) -> Result<Rc<Map>, Error>

Source

pub fn function(&self) -> Result<&Rc<Function>, Error>

Source

pub fn is_function(&self) -> bool

Source

pub fn into_function(self) -> Result<Rc<Function>, Error>

Source

pub fn native_function(&self) -> Result<&Rc<NativeFunction>, Error>

Source

pub fn is_native_function(&self) -> bool

Source

pub fn into_native_function(self) -> Result<Rc<NativeFunction>, Error>

Source

pub fn class(&self) -> Result<&Rc<Class>, Error>

Source

pub fn into_class(self) -> Result<Rc<Class>, Error>

Source

pub fn module(&self) -> Result<&Rc<Module>, Error>

Source

pub fn into_module(self) -> Result<Rc<Module>, Error>

Source

pub fn into_handle<T>(self) -> Result<Handle<T>, Error>
where T: Any,

Source

pub fn is_handle<T>(&self) -> bool
where T: Any,

Source

pub fn unwrap_handle<T>(self) -> Result<T, Error>
where T: Any,

Source

pub fn unwrap_or_clone_handle<T>(self) -> Result<T, Error>
where T: Any + Clone,

Source

pub fn convert_to_int(self) -> Result<i64, Error>

Source

pub fn convert_to_float(self) -> Result<f64, Error>

Source

pub fn convert_to_rcstr(self) -> RcStr

Source

pub fn unwrap_or_clone_string(self) -> Result<String, Error>

Source

pub fn iter(self, _globals: &mut Globals) -> Result<Value, Error>

Source

pub fn get_class<'a>(&'a self, globals: &'a Globals) -> &'a Rc<Class>

Source

pub fn getattr_opt(&self, attr: &RcStr) -> Option<Value>

Source

pub fn getattr(&self, attr: &RcStr) -> Result<Value, Error>

Source

pub fn getattrs(&self) -> Vec<RcStr>

Source

pub fn setattr(&self, attr: &RcStr, value: Value) -> Result<(), Error>

Source

pub fn apply( &self, globals: &mut Globals, args: Vec<Value>, kwargs: Option<HashMap<RcStr, Value>>, ) -> Result<Value, Error>

Source

pub fn apply_method<M>( &self, globals: &mut Globals, method_name: &M, args: Vec<Value>, kwargs: Option<HashMap<RcStr, Value>>, ) -> Result<Value, Error>
where M: Hash + Eq + Debug + ?Sized, RcStr: Borrow<M>,

Source

pub fn resume(&self, globals: &mut Globals, arg: Value) -> ResumeResult

Source

pub fn to_index(&self, len: usize) -> Result<usize, Error>

Source

pub fn to_slice_index(&self, len: usize) -> Result<usize, Error>

Source

pub fn to_start_index(&self, len: usize) -> Result<usize, Error>

Source

pub fn to_end_index(&self, len: usize) -> Result<usize, Error>

Source

pub fn getitem( &self, globals: &mut Globals, index: Value, ) -> Result<Value, Error>

Source

pub fn setitem( &self, globals: &mut Globals, index: Value, value: Value, ) -> Result<(), Error>

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

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

impl Display for Value

Source§

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

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

impl From<&ConstVal> for Value

Source§

fn from(cv: &ConstVal) -> Value

Converts to this type from the input type.
Source§

impl From<&Key> for Value

Source§

fn from(key: &Key) -> Value

Converts to this type from the input type.
Source§

impl From<&Rc<Class>> for Value

Source§

fn from(cls: &Rc<Class>) -> Value

Converts to this type from the input type.
Source§

impl From<&Rc<Function>> for Value

Source§

fn from(f: &Rc<Function>) -> Value

Converts to this type from the input type.
Source§

impl From<&Rc<Module>> for Value

Source§

fn from(m: &Rc<Module>) -> Value

Converts to this type from the input type.
Source§

impl From<&Rc<NativeFunction>> for Value

Source§

fn from(f: &Rc<NativeFunction>) -> Value

Converts to this type from the input type.
Source§

impl From<&Rc<Table>> for Value

Source§

fn from(obj: &Rc<Table>) -> Value

Converts to this type from the input type.
Source§

impl From<&RcStr> for Value

Source§

fn from(s: &RcStr) -> Value

Converts to this type from the input type.
Source§

impl From<&String> for Value

Source§

fn from(s: &String) -> Value

Converts to this type from the input type.
Source§

impl From<&str> for Value

Source§

fn from(s: &str) -> Value

Converts to this type from the input type.
Source§

impl From<(&Key, &Value)> for Value

Source§

fn from(kv: (&Key, &Value)) -> Value

Converts to this type from the input type.
Source§

impl From<()> for Value

Source§

fn from(_: ()) -> Value

Converts to this type from the input type.
Source§

impl<A, B> From<(A, B)> for Value
where Value: From<A> + From<B>,

Source§

fn from(kv: (A, B)) -> Value

Converts to this type from the input type.
Source§

impl From<ConstVal> for Value

Source§

fn from(cv: ConstVal) -> Value

Converts to this type from the input type.
Source§

impl From<Error> for Value

Source§

fn from(error: Error) -> Value

Converts to this type from the input type.
Source§

impl From<Function> for Value

Source§

fn from(f: Function) -> Value

Converts to this type from the input type.
Source§

impl From<Generator> for Value

Source§

fn from(gen: Generator) -> Value

Converts to this type from the input type.
Source§

impl<T> From<Handle<T>> for Value
where T: Any,

Source§

fn from(handle: Handle<T>) -> Value

Converts to this type from the input type.
Source§

impl From<HashMap<RcStr, Value>> for Value

Source§

fn from(map: HashMap<RcStr, Value>) -> Value

Converts to this type from the input type.
Source§

impl From<IndexMap<Key, Value>> for Value

Source§

fn from(map: IndexMap<Key, Value>) -> Value

Converts to this type from the input type.
Source§

impl From<IndexSet<Key>> for Value

Source§

fn from(set: IndexSet<Key>) -> Value

Converts to this type from the input type.
Source§

impl From<Key> for Value

Source§

fn from(key: Key) -> Value

Converts to this type from the input type.
Source§

impl From<Map> for Value

Source§

fn from(map: Map) -> Value

Converts to this type from the input type.
Source§

impl From<NativeFunction> for Value

Source§

fn from(f: NativeFunction) -> Value

Converts to this type from the input type.
Source§

impl From<NativeGenerator> for Value

Source§

fn from(gen: NativeGenerator) -> Value

Converts to this type from the input type.
Source§

impl From<Rc<Class>> for Value

Source§

fn from(cls: Rc<Class>) -> Value

Converts to this type from the input type.
Source§

impl From<Rc<Function>> for Value

Source§

fn from(f: Rc<Function>) -> Value

Converts to this type from the input type.
Source§

impl From<Rc<Module>> for Value

Source§

fn from(m: Rc<Module>) -> Value

Converts to this type from the input type.
Source§

impl From<Rc<NativeFunction>> for Value

Source§

fn from(f: Rc<NativeFunction>) -> Value

Converts to this type from the input type.
Source§

impl From<Rc<Table>> for Value

Source§

fn from(obj: Rc<Table>) -> Value

Converts to this type from the input type.
Source§

impl From<RcStr> for Value

Source§

fn from(s: RcStr) -> Value

Converts to this type from the input type.
Source§

impl From<Set> for Value

Source§

fn from(set: Set) -> Value

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(s: String) -> Value

Converts to this type from the input type.
Source§

impl From<Table> for Value

Source§

fn from(obj: Table) -> Value

Converts to this type from the input type.
Source§

impl From<Vec<Value>> for Value

Source§

fn from(vec: Vec<Value>) -> Value

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(x: bool) -> Value

Converts to this type from the input type.
Source§

impl From<char> for Value

Source§

fn from(c: char) -> Value

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(x: f32) -> Value

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(x: f64) -> Value

Converts to this type from the input type.
Source§

impl From<i16> for Value

Source§

fn from(x: i16) -> Value

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(x: i32) -> Value

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(x: i64) -> Value

Converts to this type from the input type.
Source§

impl From<i8> for Value

Source§

fn from(x: i8) -> Value

Converts to this type from the input type.
Source§

impl From<isize> for Value

Source§

fn from(x: isize) -> Value

Converts to this type from the input type.
Source§

impl From<u16> for Value

Source§

fn from(x: u16) -> Value

Converts to this type from the input type.
Source§

impl From<u32> for Value

Source§

fn from(x: u32) -> Value

Converts to this type from the input type.
Source§

impl From<u64> for Value

Source§

fn from(x: u64) -> Value

Converts to this type from the input type.
Source§

impl From<u8> for Value

Source§

fn from(x: u8) -> Value

Converts to this type from the input type.
Source§

impl From<usize> for Value

Source§

fn from(x: usize) -> Value

Converts to this type from the input type.
Source§

impl FromIterator<Value> for List

Source§

fn from_iter<I>(iter: I) -> List
where I: IntoIterator<Item = Value>,

Creates a value from an iterator. Read more
Source§

impl PartialEq for Value

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Value

Source§

fn partial_cmp(&self, other: &Value) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl TryFrom<&OsStr> for Value

Source§

type Error = Error

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

fn try_from(s: &OsStr) -> Result<Value, Error>

Performs the conversion.
Source§

impl TryFrom<&OsString> for Value

Source§

type Error = Error

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

fn try_from(s: &OsString) -> Result<Value, Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Value> for &'a str

Source§

type Error = Error

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

fn try_from(value: &'a Value) -> Result<&'a str, Error>

Performs the conversion.
Source§

impl TryFrom<&Value> for Key

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<Key, Error>

Performs the conversion.
Source§

impl TryFrom<&Value> for RcStr

Source§

type Error = Error

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

fn try_from(value: &Value) -> Result<RcStr, Error>

Performs the conversion.
Source§

impl TryFrom<OsString> for Value

Source§

type Error = Error

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

fn try_from(s: OsString) -> Result<Value, Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Encoding

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Encoding, Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Error

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Error, Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Key

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Key, Error>

Performs the conversion.
Source§

impl TryFrom<Value> for RcStr

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<RcStr, Error>

Performs the conversion.
Source§

impl<T, E> TryFrom<Value> for Vec<T>
where T: TryFrom<Value, Error = E>, Error: From<E>,

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Vec<T>, Error>

Performs the conversion.
Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin for Value

§

impl !UnwindSafe 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> 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> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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 = 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V