pub struct Py<T: PyObjectPayload>(/* private fields */);
Implementations§
Source§impl Py<PyDict>
impl Py<PyDict>
Sourcepub fn to_attributes(
&self,
vm: &VirtualMachine,
) -> IndexMap<&'static PyStrInterned, PyObjectRef, RandomState>
pub fn to_attributes( &self, vm: &VirtualMachine, ) -> IndexMap<&'static PyStrInterned, PyObjectRef, RandomState>
Take a python dictionary and convert it to attributes.
pub fn get_item_opt<K: DictKey + ?Sized>( &self, key: &K, vm: &VirtualMachine, ) -> PyResult<Option<PyObjectRef>>
pub fn get_item<K: DictKey + ?Sized>( &self, key: &K, vm: &VirtualMachine, ) -> PyResult
pub fn set_item<K: DictKey + ?Sized>( &self, key: &K, value: PyObjectRef, vm: &VirtualMachine, ) -> PyResult<()>
pub fn del_item<K: DictKey + ?Sized>( &self, key: &K, vm: &VirtualMachine, ) -> PyResult<()>
pub fn get_chain<K: DictKey + ?Sized>( &self, other: &Self, key: &K, vm: &VirtualMachine, ) -> PyResult<Option<PyObjectRef>>
Source§impl Py<PyModule>
impl Py<PyModule>
pub fn __init_methods(&self, vm: &VirtualMachine) -> PyResult<()>
pub fn dict(&self) -> PyDictRef
pub fn get_attr<'a>( &self, attr_name: impl AsPyStr<'a>, vm: &VirtualMachine, ) -> PyResult
pub fn set_attr<'a>( &self, attr_name: impl AsPyStr<'a>, attr_value: impl Into<PyObjectRef>, vm: &VirtualMachine, ) -> PyResult<()>
Source§impl Py<PyType>
impl Py<PyType>
Sourcepub fn fast_issubclass(&self, cls: &impl Borrow<PyObject>) -> bool
pub fn fast_issubclass(&self, cls: &impl Borrow<PyObject>) -> bool
Determines if subclass
is actually a subclass of cls
, this doesn’t call subclasscheck,
so only use this if cls
is known to have not overridden the base subclasscheck magic
method.
pub fn mro_map_collect<F, R>(&self, f: F) -> Vec<R>where
F: Fn(&Self) -> R,
pub fn mro_collect(&self) -> Vec<PyRef<PyType>>
pub fn iter_base_chain(&self) -> impl Iterator<Item = &Py<PyType>>
pub fn extend_methods( &'static self, method_defs: &'static [PyMethodDef], ctx: &Context, )
Source§impl Py<Frame>
impl Py<Frame>
pub fn run(&self, vm: &VirtualMachine) -> PyResult<ExecutionResult>
pub fn yield_from_target(&self) -> Option<PyObjectRef>
pub fn is_internal_frame(&self) -> bool
pub fn next_external_frame(&self, vm: &VirtualMachine) -> Option<FrameRef>
Source§impl Py<HeapMethodDef>
impl Py<HeapMethodDef>
pub fn build_function(&self, vm: &VirtualMachine) -> PyRef<PyNativeFunction>
pub fn build_method( &self, class: &'static Py<PyType>, vm: &VirtualMachine, ) -> PyRef<PyMethodDescriptor>
Source§impl<T: PyObjectPayload> Py<T>
impl<T: PyObjectPayload> Py<T>
pub fn downgrade( &self, callback: Option<PyObjectRef>, vm: &VirtualMachine, ) -> PyResult<PyWeakRef<T>>
Trait Implementations§
Source§impl<T: PyObjectPayload> AsRef<Py<T>> for PyRefExact<T>
impl<T: PyObjectPayload> AsRef<Py<T>> for PyRefExact<T>
Source§impl<T: PyObjectPayload> Borrow<Py<T>> for PyRefExact<T>
impl<T: PyObjectPayload> Borrow<Py<T>> for PyRefExact<T>
Source§impl<T: PyObjectPayload> Debug for Py<T>
impl<T: PyObjectPayload> Debug for Py<T>
Source§impl<T: PyObjectPayload> Deref for Py<T>
impl<T: PyObjectPayload> Deref for Py<T>
Source§impl<'a> IntoIterator for &'a Py<PyDict>
impl<'a> IntoIterator for &'a Py<PyDict>
Source§impl<'a> IntoIterator for &'a Py<PyTuple>
impl<'a> IntoIterator for &'a Py<PyTuple>
Source§impl<T: PyObjectPayload> ToOwned for Py<T>
impl<T: PyObjectPayload> ToOwned for Py<T>
Source§impl<T: PyObjectPayload> Traverse for Py<T>
impl<T: PyObjectPayload> Traverse for Py<T>
Source§fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
fn traverse(&self, tracer_fn: &mut TraverseFn<'_>)
DO notice that call trace
on Py<T>
means apply tracer_fn
on Py<T>
’s children,
not like call trace
on PyRef<T>
which apply tracer_fn
on PyRef<T>
itself
Source§impl<'a, T: PyPayload> TryFromBorrowedObject<'a> for &'a Py<T>
impl<'a, T: PyPayload> TryFromBorrowedObject<'a> for &'a Py<T>
Source§fn try_from_borrowed_object(
vm: &VirtualMachine,
obj: &'a PyObject,
) -> PyResult<Self>
fn try_from_borrowed_object( vm: &VirtualMachine, obj: &'a PyObject, ) -> PyResult<Self>
Attempt to convert a Python object to a value of this type.
impl<T> Eq for Py<T>where
T: Eq + PyObjectPayload,
Auto Trait Implementations§
impl<T> !Freeze for Py<T>
impl<T> !RefUnwindSafe for Py<T>
impl<T> !Send for Py<T>
impl<T> !Sync for Py<T>
impl<T> Unpin for Py<T>where
T: Unpin,
impl<T> !UnwindSafe for Py<T>
Blanket Implementations§
Source§impl<T> AsObject for T
impl<T> AsObject for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more