pub struct Plugin { /* private fields */ }Expand description
A lexical provider scope containing operations and nested plugins.
Implementations§
Source§impl Plugin
impl Plugin
pub fn new(name: impl Into<String>) -> Self
Sourcepub fn mount(self, prefix: impl Into<String>) -> Self
pub fn mount(self, prefix: impl Into<String>) -> Self
Mounts every operation in this scope, and below it, under a path prefix.
The prefix is joined in front of each declared route path when the
application is compiled, so one module — a function returning a
Plugin — can be mounted at two prefixes by calling it twice, without
restating a handler. Prefixes nest: a mounted plugin inside a mounted
plugin serves under both. The prefix must start with /, must not end
with /, and declares no {...} parameters of its own.
Sourcepub fn with_id_namespace(self, namespace: impl Into<String>) -> Self
pub fn with_id_namespace(self, namespace: impl Into<String>) -> Self
Namespaces every operation identity in this scope, and below it.
A stable id names an operation in the contract, the documents, and
compatibility reports, so mounting the same module twice needs two
identities: with_id_namespace("v1") turns notes.create into
v1.notes.create, which also groups the operations under their own
section in a browser UI. An MCP tool declared by the operation is
prefixed the same way, so both mounts stay callable as distinct tools.
pub fn provide(self, provider: impl Into<RequestProvider>) -> Self
Sourcepub fn security_scheme(self, scheme: SecuritySchemeDescriptor) -> Self
pub fn security_scheme(self, scheme: SecuritySchemeDescriptor) -> Self
Registers an application security scheme from this plugin scope.
pub fn operation(self, operation: ExecutableOperation) -> Self
pub fn routes( self, operations: impl IntoIterator<Item = ExecutableOperation>, ) -> Self
pub fn plugin(self, plugin: Self) -> Self
Sourcepub fn on_request<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext) -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
pub fn on_request<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext) -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
Adds a fallible async hook that runs before dependency resolution.
Sourcepub fn pre_parse<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext) -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
pub fn pre_parse<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext) -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
Adds a fallible async hook before typed input extraction begins.
Sourcepub fn pre_validate<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext) -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
pub fn pre_validate<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext) -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
Adds a fallible async hook immediately before input validation.
Sourcepub fn pre_handler<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext) -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
pub fn pre_handler<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext) -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
Adds a fallible async hook after input preparation and before the user handler future is polled.
Sourcepub fn pre_serialize<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext) -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
pub fn pre_serialize<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext) -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
Adds a fallible async hook after the handler and before transport response projection.
Sourcepub fn on_error<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext, HookOutcome) -> HookFuture + 'static,
HookFuture: Future<Output = ()> + 'static,
pub fn on_error<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext, HookOutcome) -> HookFuture + 'static,
HookFuture: Future<Output = ()> + 'static,
Adds an async observer for rejected, domain-error, and internal-error outcomes.
Sourcepub fn on_response<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext, HookOutcome) -> HookFuture + 'static,
HookFuture: Future<Output = ()> + 'static,
pub fn on_response<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn(HookContext, HookOutcome) -> HookFuture + 'static,
HookFuture: Future<Output = ()> + 'static,
Adds an async observer that runs after the handler and DI finalizers.
Sourcepub fn on_startup<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn() -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
pub fn on_startup<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn() -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
Adds a fallible async application startup hook.
Startup executes parent hooks before child hooks. A failure stops startup before the server accepts requests.
Sourcepub fn on_shutdown<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn() -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
pub fn on_shutdown<Hook, HookFuture>(self, hook: Hook) -> Selfwhere
Hook: Fn() -> HookFuture + 'static,
HookFuture: Future<Output = Result<(), DependencyError>> + 'static,
Adds a fallible async application shutdown hook.
Shutdown executes child hooks before parent hooks and continues after a failure so every registered cleanup receives a chance to run.