pub struct Connection { /* private fields */ }Expand description
A live connection to one RPC proxy.
Dropping it ends both background tasks and releases the socket. That is not
automatic: the writer stops on its own once the last sender is gone, but the
reader would stay parked in receive() holding the read half until the peer
closed — and against a peer that never does, the task and its file
descriptor would live as long as the process.
Implementations§
Source§impl Connection
impl Connection
Sourcepub async fn connect(address: &str, token: Option<String>) -> Result<Self>
pub async fn connect(address: &str, token: Option<String>) -> Result<Self>
Connects to a proxy and starts the reader and writer tasks.
Sourcepub async fn invoke<Response: Message + Default>(
&self,
method: &str,
body: &impl Message,
attachments: Vec<Bytes>,
timeout: Option<Duration>,
response_name: &'static str,
) -> Result<(Response, Vec<Bytes>)>
pub async fn invoke<Response: Message + Default>( &self, method: &str, body: &impl Message, attachments: Vec<Bytes>, timeout: Option<Duration>, response_name: &'static str, ) -> Result<(Response, Vec<Bytes>)>
Calls one method and waits for its response.
The timeout is sent to the server in the request header and applied locally, so the two agree: a local-only timeout would leave the proxy working, and a server-only one would leave the caller waiting if the connection stalled.
Trait Implementations§
Source§impl Debug for Connection
impl Debug for Connection
Source§impl Drop for Connection
impl Drop for Connection
Auto Trait Implementations§
impl !RefUnwindSafe for Connection
impl !UnwindSafe for Connection
impl Freeze for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
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