pub struct MuseClient { /* private fields */ }Expand description
A client connected to one host over MSP.
Create one with MuseClient::spawn (a host process the SDK starts) or
MuseClient::attach (a transport you provide). Then open sessions with
MuseClient::start_session or MuseClient::resume_session, and call
MuseClient::close when you are done.
Implementations§
Source§impl MuseClient
impl MuseClient
Sourcepub async fn start_session(
&self,
options: StartSessionOptions,
) -> FacadeResult<Session>
pub async fn start_session( &self, options: StartSessionOptions, ) -> FacadeResult<Session>
Starts a new session and returns its handle once the server accepts it.
Sourcepub async fn resume_session(
&self,
options: ResumeSessionOptions,
) -> FacadeResult<Session>
pub async fn resume_session( &self, options: ResumeSessionOptions, ) -> FacadeResult<Session>
Approvals the resume result lists as pending keep the no-handler path
fixed at handoff: each is denied when its payload arrives, and a later
Session::on_approval handles only other requests.
Sourcepub async fn resume_session_with_approval_handler<Handler, HandlerFuture>(
&self,
options: ResumeSessionOptions,
handler: Handler,
) -> FacadeResult<Session>where
Handler: Fn(ApprovalRequestParams) -> HandlerFuture + Send + Sync + 'static,
HandlerFuture: Future<Output = ApprovalDecisionInput> + Send + 'static,
pub async fn resume_session_with_approval_handler<Handler, HandlerFuture>(
&self,
options: ResumeSessionOptions,
handler: Handler,
) -> FacadeResult<Session>where
Handler: Fn(ApprovalRequestParams) -> HandlerFuture + Send + Sync + 'static,
HandlerFuture: Future<Output = ApprovalDecisionInput> + Send + 'static,
Installs handler before route handoff, so it also answers approvals
the resume result lists as pending, even if Session::on_approval
replaces it later, unless the session has since settled
that approval’s turn, which gets the rejecting choice.
Source§impl MuseClient
impl MuseClient
Sourcepub async fn spawn(options: SpawnOptions) -> FacadeResult<MuseClientConnection>
pub async fn spawn(options: SpawnOptions) -> FacadeResult<MuseClientConnection>
Spawns an SDK-owned host and completes initialize over its stdio.
Sourcepub async fn attach<T>(transport: T) -> FacadeResult<MuseClientConnection>where
T: DuplexTransport + 'static,
pub async fn attach<T>(transport: T) -> FacadeResult<MuseClientConnection>where
T: DuplexTransport + 'static,
Completes initialize over a caller-provided transport.
Sourcepub fn new<T>(transport: T, durability: SessionDurability) -> Selfwhere
T: DuplexTransport + 'static,
pub fn new<T>(transport: T, durability: SessionDurability) -> Selfwhere
T: DuplexTransport + 'static,
Low-level constructor used by deterministic facade contract tests.
§Panics
Panics when called outside a Tokio runtime because the connection driver must run on the caller-owned runtime.
Sourcepub fn with_command_id_minter<T, F>(
transport: T,
durability: SessionDurability,
minter: F,
) -> Self
pub fn with_command_id_minter<T, F>( transport: T, durability: SessionDurability, minter: F, ) -> Self
Builds a deterministic-minter client on the current Tokio runtime.
§Panics
Panics when called outside a Tokio runtime because the connection driver must run on the caller-owned runtime.
Sourcepub async fn close(&self)
pub async fn close(&self)
Close the connection, then a spawned host through its bounded ladder:
a host that honours stdin EOF exits at once, while one that ignores it
is held for SpawnOptions::shutdown_timeout (thirty seconds by
default; zero skips that window) before escalation, so a slow close is
the host’s drain window, not a hang. Teardown runs
on the client’s runtime; every call returns once it has finished (or
that runtime dropped it), and cancelling a caller does not stop it.
Sourcepub fn initialize_result(&self) -> Option<&InitializeResult>
pub fn initialize_result(&self) -> Option<&InitializeResult>
The initialize result this client’s handshake returned; None only
for MuseClient::new and MuseClient::with_command_id_minter,
which run no handshake.
Sourcepub fn durability(&self) -> SessionDurabilityProfile
pub fn durability(&self) -> SessionDurabilityProfile
The durability profile every session this client opens inherits.
Sourcepub async fn exit(&self) -> Option<Result<ExitClassification>>
pub async fn exit(&self) -> Option<Result<ExitClassification>>
Waits for the spawned host’s classified exit; None when this client
owns no host (MuseClient::attach and the low-level constructors).
Every awaiter reads the one row observed first, from the host’s own
exit or from MuseClient::close’s ladder, so awaiting it never
delays close(). It settles with an I/O error instead of staying
pending once no exit can be observed: the ladder or the wait failed,
or the runtime that owned the client’s host watcher shut down.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Whether MuseClient::close has been called.
Sourcepub fn is_session_discarded(&self, session_id: &str) -> bool
pub fn is_session_discarded(&self, session_id: &str) -> bool
Whether the session with this id was discarded: its transport ended on
a client that is not durable. Resuming it fails with
MuseError::SessionDiscarded.
Sourcepub fn is_command_discarded(&self, command_id: &str) -> bool
pub fn is_command_discarded(&self, command_id: &str) -> bool
Reports discard evidence retained by a live session’s bounded turn history.