pub struct ClientSession { /* private fields */ }
Expand description
Client session that manages connection lifecycle and notifications
Implementationsยง
Sourceยงimpl ClientSession
impl ClientSession
Sourcepub fn with_config(client: McpClient, config: SessionConfig) -> Self
pub fn with_config(client: McpClient, config: SessionConfig) -> Self
Create a new client session with custom configuration
Sourcepub async fn state(&self) -> SessionState
pub async fn state(&self) -> SessionState
Get the current session state
Sourcepub fn subscribe_state_changes(&self) -> Receiver<SessionState>
pub fn subscribe_state_changes(&self) -> Receiver<SessionState>
Subscribe to state changes
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if the session is connected
Sourcepub async fn add_notification_handler<H>(&self, handler: H)where
H: NotificationHandler + 'static,
pub async fn add_notification_handler<H>(&self, handler: H)where
H: NotificationHandler + 'static,
Add a notification handler
Sourcepub async fn connect<T>(&self, transport: T) -> McpResult<InitializeResult>where
T: Transport + 'static,
pub async fn connect<T>(&self, transport: T) -> McpResult<InitializeResult>where
T: Transport + 'static,
Connect to the server with the provided transport
Sourcepub async fn disconnect(&self) -> McpResult<()>
pub async fn disconnect(&self) -> McpResult<()>
Disconnect from the server
Sourcepub async fn reconnect<T>(
&self,
transport_factory: impl Fn() -> T,
) -> McpResult<InitializeResult>where
T: Transport + 'static,
pub async fn reconnect<T>(
&self,
transport_factory: impl Fn() -> T,
) -> McpResult<InitializeResult>where
T: Transport + 'static,
Reconnect to the server
Sourcepub fn client(&self) -> Arc<Mutex<McpClient>>
pub fn client(&self) -> Arc<Mutex<McpClient>>
Get the underlying client (for direct operations)
Sourcepub fn config(&self) -> &SessionConfig
pub fn config(&self) -> &SessionConfig
Get session configuration
Sourceยงimpl ClientSession
impl ClientSession
Sourcepub async fn stats(&self) -> SessionStats
pub async fn stats(&self) -> SessionStats
Get session statistics
Auto Trait Implementationsยง
impl Freeze for ClientSession
impl !RefUnwindSafe for ClientSession
impl Send for ClientSession
impl Sync for ClientSession
impl Unpin for ClientSession
impl !UnwindSafe for ClientSession
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