Struct cpython::PyType
[−]
[src]
pub struct PyType(_);
Represents a reference to a Python type object.
Methods
impl PyType
[src]
fn as_type_ptr(&self) -> *mut PyTypeObject
[src]
Retrieves the underlying FFI pointer associated with this Python object.
unsafe fn from_type_ptr(py: Python, p: *mut PyTypeObject) -> PyType
[src]
Retrieves the PyType instance for the given FFI pointer. This increments the reference count on the type object. Undefined behavior if the pointer is NULL or invalid.
fn name<'a>(&'a self, _py: Python<'a>) -> Cow<'a, str>
[src]
Gets the name of the PyType.
fn is_subtype_of(&self, _: Python, b: &PyType) -> bool
[src]
Return true if self
is a subtype of b
.
fn is_instance(&self, _: Python, obj: &PyObject) -> bool
[src]
Return true if obj
is an instance of self
.
fn call<A>(
&self,
py: Python,
args: A,
kwargs: Option<&PyDict>
) -> PyResult<PyObject> where
A: ToPyObject<ObjectType = PyTuple>,
[src]
&self,
py: Python,
args: A,
kwargs: Option<&PyDict>
) -> PyResult<PyObject> where
A: ToPyObject<ObjectType = PyTuple>,
Calls the type object, thus creating a new instance.
This is equivalent to the Python expression: self(*args, **kwargs)
Trait Implementations
impl ToPyObject for PyType
[src]
Identity conversion: allows using existing PyObject
instances where
T: ToPyObject
is expected.
type ObjectType = PyType
fn to_py_object(&self, py: Python) -> PyType
[src]
Converts self into a Python object.
fn into_py_object(self, _py: Python) -> PyType
[src]
Converts self into a Python object. Read more
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R,
[src]
F: FnOnce(*mut PyObject) -> R,
Converts self into a Python object and calls the specified closure on the native FFI pointer underlying the Python object. Read more
impl<'source> FromPyObject<'source> for PyType
[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<PyType>
[src]
Extracts Self
from the source PyObject
.
impl<'source> FromPyObject<'source> for &'source PyType
[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<&'source PyType>
[src]
Extracts Self
from the source PyObject
.
impl PythonObject for PyType
[src]
fn as_object(&self) -> &PyObject
[src]
Casts the Python object to PyObject.
fn into_object(self) -> PyObject
[src]
Casts the Python object to PyObject.
unsafe fn unchecked_downcast_from(obj: PyObject) -> Self
[src]
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
unsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self
[src]
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
impl PythonObjectWithCheckedDowncast for PyType
[src]
fn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PyType, PythonObjectDowncastError<'p>>
[src]
py: Python<'p>,
obj: PyObject
) -> Result<PyType, PythonObjectDowncastError<'p>>
Cast from PyObject to a concrete Python object type.
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyType, PythonObjectDowncastError<'p>>
[src]
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyType, PythonObjectDowncastError<'p>>
Cast from PyObject to a concrete Python object type.
impl PythonObjectWithTypeObject for PyType
[src]
fn type_object(py: Python) -> PyType
[src]
Retrieves the type object for this Python object type.
impl PartialEq for PyType
[src]
fn eq(&self, o: &PyType) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.