[−][src]Struct pyo3::pyclass::PyClassShell
PyClassShell
represents the concrete layout of T: PyClass
when it is converted
to a Python class.
You can use it to test your #[pyclass]
correctly works.
#[pyclass] struct Book { #[pyo3(get)] name: &'static str, author: &'static str, } let gil = Python::acquire_gil(); let py = gil.python(); let book = Book { name: "The Man in the High Castle", author: "Philip Kindred Dick", }; let book_shell = PyClassShell::new_ref(py, book).unwrap(); py_run!(py, book_shell, "assert book_shell.name[-6:] == 'Castle'");
Methods
impl<T: PyClass> PyClassShell<T>
[src]
pub fn new_ref(
py: Python,
value: impl Into<PyClassInitializer<T>>
) -> PyResult<&Self> where
<T::BaseType as PyTypeInfo>::ConcreteLayout: PyObjectSizedLayout<T::BaseType>,
[src]
py: Python,
value: impl Into<PyClassInitializer<T>>
) -> PyResult<&Self> where
<T::BaseType as PyTypeInfo>::ConcreteLayout: PyObjectSizedLayout<T::BaseType>,
Make new PyClassShell
on the Python heap and returns the reference of it.
pub fn new_mut(
py: Python,
value: impl Into<PyClassInitializer<T>>
) -> PyResult<&mut Self> where
<T::BaseType as PyTypeInfo>::ConcreteLayout: PyObjectSizedLayout<T::BaseType>,
[src]
py: Python,
value: impl Into<PyClassInitializer<T>>
) -> PyResult<&mut Self> where
<T::BaseType as PyTypeInfo>::ConcreteLayout: PyObjectSizedLayout<T::BaseType>,
Make new PyClassShell
on the Python heap and returns the mutable reference of it.
pub fn get_super(&self) -> &<T::BaseType as PyTypeInfo>::ConcreteLayout
[src]
Get the reference of base object.
pub fn get_super_mut(
&mut self
) -> &mut <T::BaseType as PyTypeInfo>::ConcreteLayout
[src]
&mut self
) -> &mut <T::BaseType as PyTypeInfo>::ConcreteLayout
Get the mutable reference of base object.
Trait Implementations
impl<T: PyClass> AsPyPointer for PyClassShell<T>
[src]
impl<T: PyClass> Deref for PyClassShell<T>
[src]
impl<T: PyClass> DerefMut for PyClassShell<T>
[src]
impl<'a, '_, T> From<&'_ PyClassShell<T>> for Py<T> where
T: PyClass,
[src]
T: PyClass,
fn from(shell: &PyClassShell<T>) -> Self
[src]
impl<'a, '_, T> From<&'_ mut PyClassShell<T>> for Py<T> where
T: PyClass,
[src]
T: PyClass,
fn from(shell: &mut PyClassShell<T>) -> Self
[src]
impl<'p, T> FromPyPointer<'p> for &'p PyClassShell<T> where
T: PyClass,
[src]
T: PyClass,
unsafe fn from_owned_ptr_or_opt(
py: Python<'p>,
ptr: *mut PyObject
) -> Option<Self>
[src]
py: Python<'p>,
ptr: *mut PyObject
) -> Option<Self>
unsafe fn from_borrowed_ptr_or_opt(
py: Python<'p>,
ptr: *mut PyObject
) -> Option<Self>
[src]
py: Python<'p>,
ptr: *mut PyObject
) -> Option<Self>
unsafe fn from_owned_ptr_or_panic(py: Python<'p>, ptr: *mut PyObject) -> Self
[src]
unsafe fn from_owned_ptr(py: Python<'p>, ptr: *mut PyObject) -> Self
[src]
unsafe fn from_owned_ptr_or_err(
py: Python<'p>,
ptr: *mut PyObject
) -> PyResult<Self>
[src]
py: Python<'p>,
ptr: *mut PyObject
) -> PyResult<Self>
unsafe fn from_borrowed_ptr_or_panic(py: Python<'p>, ptr: *mut PyObject) -> Self
[src]
unsafe fn from_borrowed_ptr(py: Python<'p>, ptr: *mut PyObject) -> Self
[src]
unsafe fn from_borrowed_ptr_or_err(
py: Python<'p>,
ptr: *mut PyObject
) -> PyResult<Self>
[src]
py: Python<'p>,
ptr: *mut PyObject
) -> PyResult<Self>
impl<'p, T> FromPyPointer<'p> for &'p mut PyClassShell<T> where
T: PyClass,
[src]
T: PyClass,
unsafe fn from_owned_ptr_or_opt(
py: Python<'p>,
ptr: *mut PyObject
) -> Option<Self>
[src]
py: Python<'p>,
ptr: *mut PyObject
) -> Option<Self>
unsafe fn from_borrowed_ptr_or_opt(
py: Python<'p>,
ptr: *mut PyObject
) -> Option<Self>
[src]
py: Python<'p>,
ptr: *mut PyObject
) -> Option<Self>
unsafe fn from_owned_ptr_or_panic(py: Python<'p>, ptr: *mut PyObject) -> Self
[src]
unsafe fn from_owned_ptr(py: Python<'p>, ptr: *mut PyObject) -> Self
[src]
unsafe fn from_owned_ptr_or_err(
py: Python<'p>,
ptr: *mut PyObject
) -> PyResult<Self>
[src]
py: Python<'p>,
ptr: *mut PyObject
) -> PyResult<Self>
unsafe fn from_borrowed_ptr_or_panic(py: Python<'p>, ptr: *mut PyObject) -> Self
[src]
unsafe fn from_borrowed_ptr(py: Python<'p>, ptr: *mut PyObject) -> Self
[src]
unsafe fn from_borrowed_ptr_or_err(
py: Python<'p>,
ptr: *mut PyObject
) -> PyResult<Self>
[src]
py: Python<'p>,
ptr: *mut PyObject
) -> PyResult<Self>
impl<T: PyClass> PyObjectLayout<T> for PyClassShell<T>
[src]
const IS_NATIVE_TYPE: bool
[src]
fn get_super_or(
&mut self
) -> Option<&mut <T::BaseType as PyTypeInfo>::ConcreteLayout>
[src]
&mut self
) -> Option<&mut <T::BaseType as PyTypeInfo>::ConcreteLayout>
unsafe fn internal_ref_cast(obj: &PyAny) -> &T
[src]
unsafe fn internal_mut_cast(obj: &PyAny) -> &mut T
[src]
unsafe fn py_drop(&mut self, py: Python)
[src]
unsafe fn py_init(&mut self, value: T)
[src]
impl<T: PyClass> PyObjectSizedLayout<T> for PyClassShell<T>
[src]
impl<'_, T: PyClass> ToPyObject for &'_ PyClassShell<T>
[src]
impl<'_, T: PyClass> ToPyObject for &'_ mut PyClassShell<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for PyClassShell<T> where
T: RefUnwindSafe,
<<T as PyTypeInfo>::BaseType as PyTypeInfo>::ConcreteLayout: RefUnwindSafe,
<T as PyClass>::Dict: RefUnwindSafe,
<T as PyClass>::WeakRef: RefUnwindSafe,
T: RefUnwindSafe,
<<T as PyTypeInfo>::BaseType as PyTypeInfo>::ConcreteLayout: RefUnwindSafe,
<T as PyClass>::Dict: RefUnwindSafe,
<T as PyClass>::WeakRef: RefUnwindSafe,
impl<T> Send for PyClassShell<T> where
T: Send,
<<T as PyTypeInfo>::BaseType as PyTypeInfo>::ConcreteLayout: Send,
<T as PyClass>::Dict: Send,
<T as PyClass>::WeakRef: Send,
T: Send,
<<T as PyTypeInfo>::BaseType as PyTypeInfo>::ConcreteLayout: Send,
<T as PyClass>::Dict: Send,
<T as PyClass>::WeakRef: Send,
impl<T> Sync for PyClassShell<T> where
T: Sync,
<<T as PyTypeInfo>::BaseType as PyTypeInfo>::ConcreteLayout: Sync,
<T as PyClass>::Dict: Sync,
<T as PyClass>::WeakRef: Sync,
T: Sync,
<<T as PyTypeInfo>::BaseType as PyTypeInfo>::ConcreteLayout: Sync,
<T as PyClass>::Dict: Sync,
<T as PyClass>::WeakRef: Sync,
impl<T> Unpin for PyClassShell<T> where
T: Unpin,
<<T as PyTypeInfo>::BaseType as PyTypeInfo>::ConcreteLayout: Unpin,
<T as PyClass>::Dict: Unpin,
<T as PyClass>::WeakRef: Unpin,
T: Unpin,
<<T as PyTypeInfo>::BaseType as PyTypeInfo>::ConcreteLayout: Unpin,
<T as PyClass>::Dict: Unpin,
<T as PyClass>::WeakRef: Unpin,
impl<T> UnwindSafe for PyClassShell<T> where
T: UnwindSafe,
<<T as PyTypeInfo>::BaseType as PyTypeInfo>::ConcreteLayout: UnwindSafe,
<T as PyClass>::Dict: UnwindSafe,
<T as PyClass>::WeakRef: UnwindSafe,
T: UnwindSafe,
<<T as PyTypeInfo>::BaseType as PyTypeInfo>::ConcreteLayout: UnwindSafe,
<T as PyClass>::Dict: UnwindSafe,
<T as PyClass>::WeakRef: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,