pub struct ModuleContext<'middleware> { /* private fields */ }Expand description
Context available while a module registers itself.
The context gives module code access to shared registries without exposing parser internals. This keeps module registration declarative and easy to copy for new teams.
Implementations§
Source§impl<'middleware> ModuleContext<'middleware>
impl<'middleware> ModuleContext<'middleware>
Sourcepub fn middleware(&self) -> &Middleware
pub fn middleware(&self) -> &Middleware
Returns a shared view of middleware while registering the module.
Sourcepub fn middleware_mut(&mut self) -> &mut Middleware
pub fn middleware_mut(&mut self) -> &mut Middleware
Returns mutable middleware for module-specific setup.
Sourcepub fn schema_registry(&mut self) -> &mut SchemaRegistry
pub fn schema_registry(&mut self) -> &mut SchemaRegistry
Returns the schema registry for direct registration.
Sourcepub fn register_schema<T: OutputSchema>(
&mut self,
command_path: impl Into<String>,
)
pub fn register_schema<T: OutputSchema>( &mut self, command_path: impl Into<String>, )
Registers a compact framework schema for a command path.
Sourcepub fn register_json_schema<T: JsonSchema>(
&mut self,
command_path: impl Into<String>,
)
pub fn register_json_schema<T: JsonSchema>( &mut self, command_path: impl Into<String>, )
Registers JSON Schema generated with schemars for a command path.
Sourcepub fn register_view(&mut self, view: HumanViewDef)
pub fn register_view(&mut self, view: HumanViewDef)
Registers a human output view and keeps it with the module.
Sourcepub fn add_guide(&mut self, guide: GuideEntry)
pub fn add_guide(&mut self, guide: GuideEntry)
Adds one guide entry.
Sourcepub fn add_guides(&mut self, guides: impl IntoIterator<Item = GuideEntry>)
pub fn add_guides(&mut self, guides: impl IntoIterator<Item = GuideEntry>)
Adds several guide entries.
Sourcepub fn add_guides_from_markdown(
&mut self,
files: impl IntoIterator<Item = (impl AsRef<Path>, impl AsRef<[u8]>)>,
)
pub fn add_guides_from_markdown( &mut self, files: impl IntoIterator<Item = (impl AsRef<Path>, impl AsRef<[u8]>)>, )
Parses and adds markdown guides from embedded (path, bytes) pairs.
Trait Implementations§
Auto Trait Implementations§
impl<'middleware> !RefUnwindSafe for ModuleContext<'middleware>
impl<'middleware> !UnwindSafe for ModuleContext<'middleware>
impl<'middleware> Freeze for ModuleContext<'middleware>
impl<'middleware> Send for ModuleContext<'middleware>
impl<'middleware> Sync for ModuleContext<'middleware>
impl<'middleware> Unpin for ModuleContext<'middleware>
impl<'middleware> UnsafeUnpin for ModuleContext<'middleware>
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