Skip to main content

TransportWireClient

Struct TransportWireClient 

Source
pub struct TransportWireClient<T: Transport> { /* private fields */ }
Expand description

A WireClient implementation backed by any Transport.

Implementations§

Source§

impl<T: Transport> TransportWireClient<T>

Source

pub const fn new(transport: T) -> Self

Create a new client wrapping the given transport.

Source

pub fn into_transport(self) -> T

Consume the client and return the underlying transport.

Source

pub const fn with_default_timeout(self, timeout: Duration) -> Self

Set a default timeout applied to every read_response call. Without this, read_response waits indefinitely for a matching id.

Source

pub const fn with_max_io_retries(self, retries: u32) -> Self

Set the maximum number of retries for transient I/O errors during read_response. Each retry waits exponentially longer (50ms * 2^attempt).

Trait Implementations§

Source§

impl<T: Transport> Debug for TransportWireClient<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Transport> WireClient for TransportWireClient<T>

Source§

fn next_id(&mut self) -> String

Generate the next request id.
Source§

async fn send_request<Params: Serialize + Sync>( &mut self, req: &JsonRpcRequest<Params>, ) -> Result<(), WireError>

Send a JSON-RPC request.
Source§

async fn read_raw_message(&mut self) -> Result<RawWireMessage, WireError>

Read the next incoming raw wire message.
Source§

async fn read_raw_message_timeout( &mut self, timeout: Duration, ) -> Result<RawWireMessage, WireError>

Read the next incoming raw wire message with a timeout.
Source§

async fn read_response<Res: DeserializeOwned + Send>( &mut self, expected_id: &str, ) -> Result<Res, WireError>

Wait for a response matching expected_id, buffering out-of-order messages internally.
Source§

async fn send_response<Res: Serialize + Send>( &mut self, id: &str, result: Res, ) -> Result<(), WireError>

Send a JSON-RPC success response.
Source§

async fn send_error( &mut self, id: &str, code: i32, message: &str, ) -> Result<(), WireError>

Send a JSON-RPC error response.
Source§

async fn initialize( &mut self, params: InitializeParams, ) -> Result<InitializeResult, WireError>

Perform the initialize handshake.
Source§

fn is_handshake_done(&self) -> bool

Returns true if the initialize handshake has completed.
Source§

async fn shutdown(self) -> Result<(), WireError>

Gracefully shut down the client.
Source§

fn prompt( &mut self, user_input: impl Into<UserInput> + Send, ) -> impl Future<Output = Result<PromptResult, WireError>> + Send

Send a prompt and wait for the result.
Source§

fn start_prompt( &mut self, user_input: impl Into<UserInput> + Send, ) -> impl Future<Output = Result<String, WireError>> + Send

Send a prompt without waiting for the result.
Source§

fn replay( &mut self, ) -> impl Future<Output = Result<ReplayResult, WireError>> + Send

Replay events and requests from the current session.
Source§

fn steer( &mut self, user_input: impl Into<UserInput> + Send, ) -> impl Future<Output = Result<SteerResult, WireError>> + Send

Steer the current turn with additional user input.
Source§

fn set_plan_mode( &mut self, enabled: bool, ) -> impl Future<Output = Result<SetPlanModeResult, WireError>> + Send

Enable or disable plan mode.
Source§

fn cancel(&mut self) -> impl Future<Output = Result<(), WireError>> + Send

Cancel the current turn.

Auto Trait Implementations§

§

impl<T> Freeze for TransportWireClient<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for TransportWireClient<T>
where T: RefUnwindSafe,

§

impl<T> Send for TransportWireClient<T>

§

impl<T> Sync for TransportWireClient<T>
where T: Sync,

§

impl<T> Unpin for TransportWireClient<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TransportWireClient<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for TransportWireClient<T>
where T: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WireClientExt for T
where T: WireClient + ?Sized,

Source§

fn read_message( &mut self, ) -> impl Future<Output = Result<WireMessage, WireError>> + Send

Read the next incoming message and parse it into a WireMessage. Read more
Source§

fn read_message_timeout( &mut self, timeout: Duration, ) -> impl Future<Output = Result<WireMessage, WireError>> + Send

Read the next incoming message with a timeout. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more