Trait pyo3::AsPyRef [−][src]
pub trait AsPyRef<T>: Sized { fn as_ref(&self, py: Python) -> &T; fn as_mut(&self, py: Python) -> &mut T; fn with<F, R>(&self, f: F) -> R
where
F: FnOnce(Python, &T) -> R, { ... } fn with_mut<F, R>(&self, f: F) -> R
where
F: FnOnce(Python, &mut T) -> R, { ... } fn into_py<F, R>(self, f: F) -> R
where
Self: IntoPyPointer,
F: FnOnce(Python, &T) -> R, { ... } fn into_mut_py<F, R>(self, f: F) -> R
where
Self: IntoPyPointer,
F: FnOnce(Python, &mut T) -> R, { ... } }
Trait implements object reference extraction from python managed pointer.
Required Methods
fn as_ref(&self, py: Python) -> &T
Return reference to object.
fn as_mut(&self, py: Python) -> &mut T
Return mutable reference to object.
Provided Methods
fn with<F, R>(&self, f: F) -> R where
F: FnOnce(Python, &T) -> R,
F: FnOnce(Python, &T) -> R,
Acquire python gil and call closure with object reference.
fn with_mut<F, R>(&self, f: F) -> R where
F: FnOnce(Python, &mut T) -> R,
F: FnOnce(Python, &mut T) -> R,
Acquire python gil and call closure with mutable object reference.
fn into_py<F, R>(self, f: F) -> R where
Self: IntoPyPointer,
F: FnOnce(Python, &T) -> R,
Self: IntoPyPointer,
F: FnOnce(Python, &T) -> R,
fn into_mut_py<F, R>(self, f: F) -> R where
Self: IntoPyPointer,
F: FnOnce(Python, &mut T) -> R,
Self: IntoPyPointer,
F: FnOnce(Python, &mut T) -> R,
Implementors
impl<T> AsPyRef<T> for Py<T> where
T: PyTypeInfo,impl<T> AsPyRef<T> for Py<T> where
T: PyTypeInfo + PyNativeType,impl AsPyRef<PyObjectRef> for PyObject