pub struct InMemoryWireClient { /* private fields */ }Expand description
In-memory wire client for unit tests.
Holds an internal queue of crate::protocol::RawWireMessages that
read_raw_message drains. Tests inject messages via InMemoryWireClient::inject.
Implementations§
Trait Implementations§
Source§impl Debug for InMemoryWireClient
impl Debug for InMemoryWireClient
Source§impl Default for InMemoryWireClient
impl Default for InMemoryWireClient
Source§impl WireClient for InMemoryWireClient
impl WireClient for InMemoryWireClient
Source§async fn send_request<Params: Serialize + Sync>(
&mut self,
req: &JsonRpcRequest<Params>,
) -> Result<(), WireError>
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>
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>
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<T: DeserializeOwned + Send>(
&mut self,
expected_id: &str,
) -> Result<T, WireError>
async fn read_response<T: DeserializeOwned + Send>( &mut self, expected_id: &str, ) -> Result<T, WireError>
Wait for a response matching
expected_id, buffering out-of-order
messages internally.Source§async fn send_response<T: Serialize + Send>(
&mut self,
id: &str,
result: T,
) -> Result<(), WireError>
async fn send_response<T: Serialize + Send>( &mut self, id: &str, result: T, ) -> Result<(), WireError>
Send a JSON-RPC success response.
Source§async fn send_error(
&mut self,
id: &str,
code: i32,
message: &str,
) -> Result<(), WireError>
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>
async fn initialize( &mut self, _params: InitializeParams, ) -> Result<InitializeResult, WireError>
Perform the initialize handshake.
Source§fn is_handshake_done(&self) -> bool
fn is_handshake_done(&self) -> bool
Returns true if the initialize handshake has completed.
Source§fn prompt(
&mut self,
user_input: impl Into<UserInput> + Send,
) -> impl Future<Output = Result<PromptResult, WireError>> + Send
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
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
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
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
fn set_plan_mode( &mut self, enabled: bool, ) -> impl Future<Output = Result<SetPlanModeResult, WireError>> + Send
Enable or disable plan mode.
Auto Trait Implementations§
impl !Freeze for InMemoryWireClient
impl !RefUnwindSafe for InMemoryWireClient
impl Send for InMemoryWireClient
impl Sync for InMemoryWireClient
impl Unpin for InMemoryWireClient
impl UnsafeUnpin for InMemoryWireClient
impl UnwindSafe for InMemoryWireClient
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