Skip to main content

MuseClient

Struct MuseClient 

Source
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

Source

pub async fn list_sessions( &self, options: ListSessionsOptions, ) -> FacadeResult<SessionListResult>

Lists the host’s stored sessions, newest activity first, one page per call. A read-only query: it opens and subscribes to nothing.

Source§

impl MuseClient

Source

pub async fn start_session( &self, options: StartSessionOptions, ) -> FacadeResult<Session>

Starts a new session and returns its handle once the server accepts it.

Source

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.

Source

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

Source

pub async fn spawn(options: SpawnOptions) -> FacadeResult<MuseClientConnection>

Spawns an SDK-owned host and completes initialize over its stdio.

Source

pub async fn attach<T>(transport: T) -> FacadeResult<MuseClientConnection>
where T: DuplexTransport + 'static,

Completes initialize over a caller-provided transport.

Source

pub fn new<T>(transport: T, durability: SessionDurability) -> Self
where 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.

Source

pub fn with_command_id_minter<T, F>( transport: T, durability: SessionDurability, minter: F, ) -> Self
where T: DuplexTransport + 'static, F: Fn() -> String + Send + Sync + 'static,

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.

Source

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.

Source

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.

Source

pub fn durability(&self) -> SessionDurabilityProfile

The durability profile every session this client opens inherits.

Source

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.

Source

pub fn is_closed(&self) -> bool

Whether MuseClient::close has been called.

Source

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.

Source

pub fn is_command_discarded(&self, command_id: &str) -> bool

Reports discard evidence retained by a live session’s bounded turn history.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.