Struct mpack::rpc::Client [] [src]

pub struct Client<R: Read + Send + 'static, W: Write + Send> { /* fields omitted */ }

Client represents a connection to some server that accepts MessagePack RPC requests.

Methods

impl<R, W> Client<R, W> where
    R: Read + Send + 'static,
    W: Write + Send
[src]

Construct a new Client instance from a stream.

In order for this to work properly, the stream's .clone() method must return a new handle to the shared underlying stream; in other words, it must be a shallow clone and not deep. TcpStream and UnixStream are known to do this, but other types should be aware of this restriction.

Construct a new Client instance.

This will spawn a main loop thread which will take ownership of the Read instance, and which will exit when it detects EOF, or when it receives a 0 in lieu of a MessagePack data type identifier.

Call a method via RPC and receive the response as a Receiver.

If an Err value is returned, it indicates some IO error that occurred while trying to make the call. An Ok value means that the call was successfully made. Calling .get() on its contents will block the thread until a response is received.

Call a method via RPC and receive the response in a closure.

If an Err value is returned, it indicates some IO error that occurred while trying to make the call, and as a result the provided closure will never be invoked. If an Ok value is returned, then a new thread will be kicked off to listen for the response and pass it to the closure when it's received.

Panics

The new thread could conceivably panic if the Client instance gets cleaned up before the callback is invoked.

Call a method via RPC and synchronously wait for the response.

If an Err value is returned, it indicates some IO error that occurred while trying to make the call. An Ok value will contain the server's response.

Trait Implementations

impl<R, W> Drop for Client<R, W> where
    R: Read + Send + 'static,
    W: Write + Send
[src]

A method called when the value goes out of scope. Read more