[][src]Struct rustpython_vm::pyobject::PyObject

pub struct PyObject<T: ?Sized> where
    T: PyObjectPayload
{ pub typ: PyClassRef, pub dict: Option<RefCell<PyDictRef>>, pub payload: T, }

This is an actual python object. It consists of a typ which is the python class, and carries some rust payload optionally. This rust payload can be a rust float or rust int in case of float and int objects.

Fields

typ: PyClassRefdict: Option<RefCell<PyDictRef>>payload: T

Methods

impl PyObject<dyn PyObjectPayload>[src]

pub fn downcast<T: PyObjectPayload>(
    self: Rc<Self>
) -> Result<PyRef<T>, PyObjectRef>
[src]

Attempt to downcast this reference to a subclass.

If the downcast fails, the original ref is returned in as Err so another downcast can be attempted without unnecessary cloning.

impl<T> PyObject<T> where
    T: Sized + PyObjectPayload
[src]

pub fn new(payload: T, typ: PyClassRef, dict: Option<PyDictRef>) -> PyObjectRef[src]

pub fn into_ref(self) -> PyObjectRef[src]

impl PyObject<dyn PyObjectPayload>[src]

pub fn payload<T: PyObjectPayload>(&self) -> Option<&T>[src]

pub fn payload_is<T: PyObjectPayload>(&self) -> bool[src]

pub fn payload_if_subclass<T: PyObjectPayload + PyValue>(
    &self,
    vm: &VirtualMachine
) -> Option<&T>
[src]

Trait Implementations

impl Debug for PyObject<dyn PyObjectPayload>[src]

impl Display for PyObject<dyn PyObjectPayload>[src]

impl<T: ?Sized + PyObjectPayload> IdProtocol for PyObject<T>[src]

impl<T: ?Sized> TypeProtocol for PyObject<T> where
    T: PyObjectPayload
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for PyObject<T>

impl<T> !Send for PyObject<T>

impl<T> !Sync for PyObject<T>

impl<T: ?Sized> Unpin for PyObject<T> where
    T: Unpin

impl<T> !UnwindSafe for PyObject<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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