pub struct PyModuleDef {
pub name: &'static PyStrInterned,
pub doc: Option<&'static PyStrInterned>,
pub methods: &'static [PyMethodDef],
pub slots: PyModuleSlots,
}Fields§
§name: &'static PyStrInterned§doc: Option<&'static PyStrInterned>§methods: &'static [PyMethodDef]§slots: PyModuleSlotsImplementations§
Source§impl PyModuleDef
impl PyModuleDef
Sourcepub fn create_module(
&'static self,
vm: &VirtualMachine,
) -> PyResult<PyRef<PyModule>>
pub fn create_module( &'static self, vm: &VirtualMachine, ) -> PyResult<PyRef<PyModule>>
Create a module from this definition (Phase 1 of multi-phase init).
This performs:
- Create module object (using create slot if provided)
- Initialize module dict from def
- Add methods to module
Does NOT add to sys.modules or call exec slot.
Sourcepub fn exec_module(
&'static self,
vm: &VirtualMachine,
module: &Py<PyModule>,
) -> PyResult<()>
pub fn exec_module( &'static self, vm: &VirtualMachine, module: &Py<PyModule>, ) -> PyResult<()>
Execute the module’s exec slot (Phase 2 of multi-phase init).
Calls the exec slot if present. Returns Ok(()) if no exec slot.
Trait Implementations§
Source§impl Debug for PyModuleDef
impl Debug for PyModuleDef
Source§impl MaybeTraverse for PyModuleDef
impl MaybeTraverse for PyModuleDef
Source§const HAS_TRAVERSE: bool = false
const HAS_TRAVERSE: bool = false
if is traceable, will be used by vtable to determine
Source§const HAS_CLEAR: bool = false
const HAS_CLEAR: bool = false
if has clear implementation for circular reference resolution (tp_clear)
fn try_traverse(&self, tracer_fn: &mut TraverseFn<'_>)
fn try_clear(&mut self, out: &mut Vec<PyObjectRef>)
Source§impl PyClassDef for PyModuleDef
impl PyClassDef for PyModuleDef
const NAME: &'static str = "module"
const MODULE_NAME: Option<&'static str> = None
const TP_NAME: &'static str = "module"
const DOC: Option<&'static str>
const BASICSIZE: usize
const UNHASHABLE: bool = false
type Base = PyBaseObject
const ITEMSIZE: usize = 0
Source§impl StaticType for PyModuleDef
impl StaticType for PyModuleDef
fn static_cell() -> &'static StaticCell<PyTypeRef>
fn static_metaclass() -> &'static Py<PyType>
fn static_baseclass() -> &'static Py<PyType>
fn static_type() -> &'static Py<PyType>
fn init_manually(typ: PyTypeRef) -> &'static Py<PyType>
Auto Trait Implementations§
impl Freeze for PyModuleDef
impl !RefUnwindSafe for PyModuleDef
impl !Send for PyModuleDef
impl !Sync for PyModuleDef
impl Unpin for PyModuleDef
impl UnsafeUnpin for PyModuleDef
impl !UnwindSafe for PyModuleDef
Blanket Implementations§
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