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 config(&self) -> &ConfigFile
pub fn config(&self) -> &ConfigFile
Returns the per-application config file as loaded at startup.
Read a consumer-owned section with
ConfigFile::section. This is
the same startup snapshot surfaced via
CommandContext::config; see
its documentation for snapshot-semantics caveats.
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.