Struct pyo3::PyModule [−][src]
pub struct PyModule(_);
Represents a Python module
object.
Methods
impl PyModule
[src]
impl PyModule
pub fn new<'p>(py: Python<'p>, name: &str) -> PyResult<&'p PyModule>
[src]
pub fn new<'p>(py: Python<'p>, name: &str) -> PyResult<&'p PyModule>
Create a new module object with the __name__
attribute set to name.
pub fn import<'p>(py: Python<'p>, name: &str) -> PyResult<&'p PyModule>
[src]
pub fn import<'p>(py: Python<'p>, name: &str) -> PyResult<&'p PyModule>
Import the Python module with the specified name.
pub fn dict(&self) -> &PyDict
[src]
pub fn dict(&self) -> &PyDict
Return the dictionary object that implements module's namespace;
this object is the same as the __dict__
attribute of the module object.
pub fn name(&self) -> PyResult<&str>
[src]
pub fn name(&self) -> PyResult<&str>
Gets the module name.
May fail if the module does not have a __name__
attribute.
pub fn filename(&self) -> PyResult<&str>
[src]
pub fn filename(&self) -> PyResult<&str>
Gets the module filename.
May fail if the module does not have a __file__
attribute.
pub fn call<A, K>(
&self,
name: &str,
args: A,
kwargs: K
) -> PyResult<&PyObjectRef> where
A: IntoPyTuple,
K: IntoPyDictPointer,
[src]
pub fn call<A, K>(
&self,
name: &str,
args: A,
kwargs: K
) -> PyResult<&PyObjectRef> where
A: IntoPyTuple,
K: IntoPyDictPointer,
Calls a function in the module.
This is equivalent to the Python expression: getattr(module, name)(*args, **kwargs)
pub fn call0(&self, name: &str) -> PyResult<&PyObjectRef>
[src]
pub fn call0(&self, name: &str) -> PyResult<&PyObjectRef>
Calls a function in the module.
This is equivalent to the Python expression: getattr(module, name)()
pub fn call1<A>(&self, name: &str, args: A) -> PyResult<&PyObjectRef> where
A: IntoPyTuple,
[src]
pub fn call1<A>(&self, name: &str, args: A) -> PyResult<&PyObjectRef> where
A: IntoPyTuple,
Calls a function in the module.
This is equivalent to the Python expression: getattr(module, name)(*args)
pub fn get(&self, name: &str) -> PyResult<&PyObjectRef>
[src]
pub fn get(&self, name: &str) -> PyResult<&PyObjectRef>
Gets a member from the module.
This is equivalent to the Python expression: getattr(module, name)
pub fn add<V>(&self, name: &str, value: V) -> PyResult<()> where
V: ToPyObject,
[src]
pub fn add<V>(&self, name: &str, value: V) -> PyResult<()> where
V: ToPyObject,
Adds a member to the module.
This is a convenience function which can be used from the module's initialization function.
pub fn add_class<T>(&self) -> PyResult<()> where
T: PyTypeInfo,
[src]
pub fn add_class<T>(&self) -> PyResult<()> where
T: PyTypeInfo,
Adds a new extension type to the module.
This is a convenience function that initializes the class
,
sets new_type.__module__
to this module's name,
and adds the type to this module.
Trait Implementations
impl<'a> From<&'a PyModule> for &'a PyObjectRef
[src]
impl<'a> From<&'a PyModule> for &'a PyObjectRef
impl AsRef<PyObjectRef> for PyModule
[src]
impl AsRef<PyObjectRef> for PyModule
fn as_ref(&self) -> &PyObjectRef
[src]
fn as_ref(&self) -> &PyObjectRef
Performs the conversion.
impl PyObjectWithToken for PyModule
[src]
impl PyObjectWithToken for PyModule
impl ToPyPointer for PyModule
[src]
impl ToPyPointer for PyModule
impl PartialEq for PyModule
[src]
impl PartialEq for PyModule
fn eq(&self, o: &PyModule) -> bool
[src]
fn eq(&self, o: &PyModule) -> bool
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]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl PyTypeInfo for PyModule
[src]
impl PyTypeInfo for PyModule
type Type = ()
Type of objects to store in PyObject struct
type BaseType = PyObjectRef
Base class
const NAME: &'static str
NAME: &'static str = "PyModule"
Class name
const SIZE: usize
SIZE: usize = ::std::mem::size_of::<::ffi::PyObject>()
Size of the rust PyObject structure (PyObject + rust structure)
const OFFSET: isize
OFFSET: isize = 0
Type
instance offset inside PyObject structure
unsafe fn type_object() -> &'static mut PyTypeObject
[src]
unsafe fn type_object() -> &'static mut PyTypeObject
PyTypeObject instance for this type
fn is_instance(ptr: *mut PyObject) -> bool
[src]
fn is_instance(ptr: *mut PyObject) -> bool
Check if *mut ffi::PyObject
is instance of this type
const DESCRIPTION: &'static str
DESCRIPTION: &'static str = "\u{0}"
Class doc string
const FLAGS: usize
FLAGS: usize = 0
Type flags (ie PY_TYPE_FLAG_GC, PY_TYPE_FLAG_WEAKREF)
fn is_exact_instance(ptr: *mut PyObject) -> bool
[src]
fn is_exact_instance(ptr: *mut PyObject) -> bool
Check if *mut ffi::PyObject
is exact instance of this type
impl PyTypeObject for PyModule
[src]
impl PyTypeObject for PyModule
fn init_type()
[src]
fn init_type()
Initialize type object
fn type_object() -> Py<PyType>
[src]
fn type_object() -> Py<PyType>
Retrieves the type object for this Python object type.
fn create(py: Python) -> PyResult<PyRawObject> where
Self: Sized + PyObjectAlloc<Self> + PyTypeInfo,
[src]
fn create(py: Python) -> PyResult<PyRawObject> where
Self: Sized + PyObjectAlloc<Self> + PyTypeInfo,
Create PyRawObject which can be initialized with rust value
impl ToPyObject for PyModule
[src]
impl ToPyObject for PyModule
impl ToBorrowedObject for PyModule
[src]
impl ToBorrowedObject for PyModule
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R,
[src]
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
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 Debug for PyModule
[src]
impl Debug for PyModule
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl Display for PyModule
[src]
impl Display for PyModule
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl<'a> FromPyObject<'a> for &'a PyModule
[src]
impl<'a> FromPyObject<'a> for &'a PyModule
fn extract(ob: &'a PyObjectRef) -> PyResult<Self>
[src]
fn extract(ob: &'a PyObjectRef) -> PyResult<Self>
Extracts Self
from the source PyObject
.