Skip to main content

RpcClientHandle

Struct RpcClientHandle 

Source
pub struct RpcClientHandle { /* private fields */ }
Expand description

Handle for the client’s background task.

Implementations§

Source§

impl RpcClientHandle

Source

pub async fn join(self) -> Result<(), JoinError>

Wait for the receive task to finish without aborting it.

Examples found in repository?
examples/rpc_client_server.rs (line 125)
84async fn run_client() -> Result<(), Box<dyn std::error::Error>> {
85    println!("[Client] Connecting to RPC server");
86
87    let transport = SharedMemoryFrameTransport::connect_client(SERVICE_NAME)?;
88    let channel = MessageChannelAdapter::new(transport);
89
90    let client = RpcClient::new(channel);
91    let handle = client.try_start()?;
92
93    println!("[Client] Connected!\n");
94
95    println!("[Client] Calling add(10, 32)");
96    let resp: AddResponse = client.call("add", &AddRequest { a: 10, b: 32 }).await?;
97    println!("[Client] Result: {}\n", resp.result);
98
99    println!("[Client] Calling add(100, 200)");
100    let resp: AddResponse = client.call("add", &AddRequest { a: 100, b: 200 }).await?;
101    println!("[Client] Result: {}\n", resp.result);
102
103    println!("[Client] Calling echo(\"Hello, RPC!\")");
104    let resp: EchoResponse = client
105        .call(
106            "echo",
107            &EchoRequest {
108                message: "Hello, RPC!".to_string(),
109            },
110        )
111        .await?;
112    println!(
113        "[Client] Result: message=\"{}\", length={}\n",
114        resp.message, resp.length
115    );
116
117    println!("[Client] Calling unknown method");
118    let result: Result<(), _> = client.call("unknown", &()).await;
119    match result {
120        Ok(_) => println!("[Client] Unexpected success"),
121        Err(e) => println!("[Client] Got expected error: {}\n", e),
122    }
123
124    let close_result = client.close().await;
125    let join_result = handle.join().await;
126    close_result?;
127    join_result?;
128    println!("[Client] Done!");
129
130    Ok(())
131}
Source

pub async fn shutdown(self)

Abort the receive task when graceful client close is not possible.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V