Skip to main content

PythonValue

Enum PythonValue 

Source
pub enum PythonValue {
    None,
    Boolean(bool),
    Integer(i64),
    Float(f64),
    String(String),
    List(Vec<Arc<PythonValue>>),
    Tuple(Vec<Arc<PythonValue>>),
    Dict(HashMap<String, Arc<PythonValue>>),
    Object(String, HashMap<String, Arc<PythonValue>>),
    Function(String),
}
Expand description

Python value type

Variants§

§

None

None value

§

Boolean(bool)

Boolean value

§

Integer(i64)

Integer value

§

Float(f64)

Float value

§

String(String)

String value

§

List(Vec<Arc<PythonValue>>)

List value

§

Tuple(Vec<Arc<PythonValue>>)

Tuple value

§

Dict(HashMap<String, Arc<PythonValue>>)

Dict value

§

Object(String, HashMap<String, Arc<PythonValue>>)

Object value

§

Function(String)

Function value

Implementations§

Source§

impl PythonValue

Source

pub fn is_none(&self) -> bool

Check if value is None

Source

pub fn to_i64(&self) -> i64

Convert value to i64

Source

pub fn to_f64(&self) -> f64

Convert value to f64

Source

pub fn to_bool(&self) -> bool

Convert value to bool

Source

pub fn to_string(&self) -> String

Convert value to string

Source

pub fn len(&self) -> usize

Get length of collection

Source

pub fn get_item(&self, index: &PythonValue) -> PythonResult<Arc<PythonValue>>

Get item from collection

Source

pub fn set_item( &mut self, index: &PythonValue, value: Arc<PythonValue>, ) -> PythonResult<()>

Set item in collection

Source

pub fn append(&mut self, value: Arc<PythonValue>) -> PythonResult<()>

Append item to list

Source

pub fn add(&self, other: &PythonValue) -> PythonResult<PythonValue>

Add two values

Source

pub fn sub(&self, other: &PythonValue) -> PythonResult<PythonValue>

Subtract two values

Source

pub fn mul(&self, other: &PythonValue) -> PythonResult<PythonValue>

Multiply two values

Source

pub fn div(&self, other: &PythonValue) -> PythonResult<PythonValue>

Divide two values

Source

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

Check equality

Source

pub fn lt(&self, other: &PythonValue) -> PythonResult<bool>

Check less than

Source

pub fn gt(&self, other: &PythonValue) -> PythonResult<bool>

Check greater than

Trait Implementations§

Source§

impl Clone for PythonValue

Source§

fn clone(&self) -> PythonValue

Returns a duplicate 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 PythonValue

Source§

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

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

impl PartialEq for PythonValue

Source§

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

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.