pub struct ModuleDef {
ffi_def: UnsafeCell<PyModuleDef>,
initializer: ModuleInitializer,
module: GILOnceCell<Py<PyModule>>,
}
Expand description
Sync
wrapper of ffi::PyModuleDef
.
Fields§
§ffi_def: UnsafeCell<PyModuleDef>
§initializer: ModuleInitializer
§module: GILOnceCell<Py<PyModule>>
Initialized module object, cached to avoid reinitialization.
Implementations§
source§impl ModuleDef
impl ModuleDef
sourcepub const unsafe fn new(
name: &'static str,
doc: &'static str,
initializer: ModuleInitializer
) -> Self
pub const unsafe fn new( name: &'static str, doc: &'static str, initializer: ModuleInitializer ) -> Self
Make new module definition with given module name.
§Safety
name
and doc
must be null-terminated strings.
sourcepub fn make_module(&'static self, py: Python<'_>) -> PyResult<Py<PyModule>>
pub fn make_module(&'static self, py: Python<'_>) -> PyResult<Py<PyModule>>
Builds a module using user given initializer. Used for #[pymodule]
.
Trait Implementations§
source§impl PyAddToModule for ModuleDef
impl PyAddToModule for ModuleDef
For adding a module to a module.
impl Sync for ModuleDef
Auto Trait Implementations§
impl !Freeze for ModuleDef
impl !RefUnwindSafe for ModuleDef
impl !Send for ModuleDef
impl Unpin for ModuleDef
impl UnwindSafe for ModuleDef
Blanket Implementations§
source§impl<T> AssertNotZeroSized for T
impl<T> AssertNotZeroSized for T
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more