Skip to main content

Connection

Struct Connection 

Source
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

Source

pub async fn connect(address: &str, token: Option<String>) -> Result<Self>

Connects to a proxy and starts the reader and writer tasks.

Source

pub fn address(&self) -> &str

The address this connection was opened to.

Source

pub fn is_closed(&self) -> bool

Whether the connection has failed or been closed.

Source

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.

Source

pub async fn invoke_raw( &self, service: &str, method: &str, body: &impl Message, attachments: Vec<Bytes>, timeout: Option<Duration>, mutation_id: Option<Guid>, ) -> Result<ResponseMessage>

Calls one method, returning the whole response message.

Trait Implementations§

Source§

impl Debug for Connection

Source§

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

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

impl Drop for Connection

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V