pub struct Module { /* private fields */ }
Expand description
A wrapped fora prolog module.
Implementations§
source§impl Module
impl Module
sourcepub unsafe fn wrap(module: module_t) -> Self
pub unsafe fn wrap(module: module_t) -> Self
Wrap a module_t
, which is how the SWI-Prolog fli represents modules.
Safety
This is unsafe because no check is done to ensure that the module_t indeed points at a valid module. The caller will have to ensure that this is the case.
sourcepub fn new<A: IntoAtom>(name: A) -> Self
pub fn new<A: IntoAtom>(name: A) -> Self
Create a new module from the given name.
This will panic if no prolog engine is active on this thread.
sourcepub fn module_ptr(&self) -> module_t
pub fn module_ptr(&self) -> module_t
Return the underlying module_t
which SWI-Prolog uses to refer to the module.
sourcepub fn with_name<F, R>(&self, func: F) -> R
pub fn with_name<F, R>(&self, func: F) -> R
Retrieve the name of this module as an atom and pass it into the given function.
The atom does not outlive this call, and the reference count is never incremented. This may be slightly faster in some cases than returning the name directly.
This will panic if no prolog engine is active on this thread.
sourcepub fn name(&self) -> Atom
pub fn name(&self) -> Atom
Retrieve the name of this module as an atom.
This will panic if no prolog engine is active on this thread.
sourcepub fn name_string(&self) -> String
pub fn name_string(&self) -> String
Retrieve the name of this module as a string.
This will panic if no prolog engine is active on this thread.