pub struct ContextFactory { /* private fields */ }
Expand description
Context factory with comprehensive lifecycle management
Implementations§
Source§impl ContextFactory
impl ContextFactory
Sourcepub fn new(config: ContextFactoryConfig, shared_container: Container) -> Self
pub fn new(config: ContextFactoryConfig, shared_container: Container) -> Self
Create a new context factory
Sourcepub async fn create_for_tool(
&self,
request_context: RequestContext,
tool_name: &str,
description: Option<&str>,
) -> McpResult<Context>
pub async fn create_for_tool( &self, request_context: RequestContext, tool_name: &str, description: Option<&str>, ) -> McpResult<Context>
Create a context for a tool handler with proper inheritance
Sourcepub async fn create_for_resource(
&self,
request_context: RequestContext,
resource_uri: &str,
) -> McpResult<Context>
pub async fn create_for_resource( &self, request_context: RequestContext, resource_uri: &str, ) -> McpResult<Context>
Create a context for a resource handler
Sourcepub async fn create_for_prompt(
&self,
request_context: RequestContext,
prompt_name: &str,
) -> McpResult<Context>
pub async fn create_for_prompt( &self, request_context: RequestContext, prompt_name: &str, ) -> McpResult<Context>
Create a context for a prompt handler
Sourcepub async fn return_to_pool(&self, context: Context)
pub async fn return_to_pool(&self, context: Context)
Return a context to the pool for reuse
Sourcepub async fn cleanup_pool(&self)
pub async fn cleanup_pool(&self)
Clean up expired contexts from pool
Sourcepub async fn current_request_scope(&self) -> Option<RequestScope>
pub async fn current_request_scope(&self) -> Option<RequestScope>
Get current request scope
Sourcepub async fn pop_request_scope(&self) -> Option<RequestScope>
pub async fn pop_request_scope(&self) -> Option<RequestScope>
Pop current request scope (when request completes)
Sourcepub fn metrics(&self) -> &ContextFactoryMetrics
pub fn metrics(&self) -> &ContextFactoryMetrics
Get factory metrics
Sourcepub fn config(&self) -> &ContextFactoryConfig
pub fn config(&self) -> &ContextFactoryConfig
Get factory configuration
Auto Trait Implementations§
impl Freeze for ContextFactory
impl !RefUnwindSafe for ContextFactory
impl Send for ContextFactory
impl Sync for ContextFactory
impl Unpin for ContextFactory
impl !UnwindSafe for ContextFactory
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