[][src]Struct pyo3::pyclass::PyClassShell

#[repr(C)]
pub struct PyClassShell<T: PyClass> { /* fields omitted */ }

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]

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]

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]

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]

type Target = T

The resulting type after dereferencing.

impl<T: PyClass> DerefMut for PyClassShell<T>[src]

impl<'a, '_, T> From<&'_ PyClassShell<T>> for Py<T> where
    T: PyClass
[src]

impl<'a, '_, T> From<&'_ mut PyClassShell<T>> for Py<T> where
    T: PyClass
[src]

impl<'p, T> FromPyPointer<'p> for &'p PyClassShell<T> where
    T: PyClass
[src]

impl<'p, T> FromPyPointer<'p> for &'p mut PyClassShell<T> where
    T: PyClass
[src]

impl<T: PyClass> PyObjectLayout<T> for PyClassShell<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

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

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

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

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

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, 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.