pub struct Connection { /* private fields */ }Expand description
A live connection to one agent. Dropping it closes the connection; the agent keeps running.
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn open(stream: TcpStream, config: HostConfig) -> Result<Connection>
pub fn open(stream: TcpStream, config: HostConfig) -> Result<Connection>
Starts a host session over stream, which the agent speaks first on.
Sourcepub fn handshake(
&self,
timeout: Duration,
) -> Result<Negotiated, DisconnectReason>
pub fn handshake( &self, timeout: Duration, ) -> Result<Negotiated, DisconnectReason>
Waits until the handshake completes, or fails with the reason the
session closed: a refused hello (another token, no common protocol
version), silence past the peer timeout, or the end of the stream.
timeout caps the wait; past it the connection is closed and the
failure is silence.
Sourcepub fn negotiated(&self) -> Option<Negotiated>
pub fn negotiated(&self) -> Option<Negotiated>
What the handshake settled, once it has.
Sourcepub fn call(&self, call: Call, deadline: Duration) -> Result<Reply, Error>
pub fn call(&self, call: Call, deadline: Duration) -> Result<Reply, Error>
Sends call with deadline and waits for its answer: the agent’s, or
the session’s own deadline_exceeded or disconnected error.
Sourcepub fn resync(&self, stream: Stream) -> Result<u32, Error>
pub fn resync(&self, stream: Stream) -> Result<u32, Error>
Asks the agent to resynchronize stream; the outcome reaches the
sink as Resynced or ResyncFailed.
Sourcepub fn set_sink(&self, sink: EventSink)
pub fn set_sink(&self, sink: EventSink)
Sets where events go from now on, after replaying those that arrived while no sink was set.
Sourcepub fn close_reason(&self) -> Option<DisconnectReason>
pub fn close_reason(&self) -> Option<DisconnectReason>
Why the connection closed, once it has.
pub fn is_closed(&self) -> bool
Trait Implementations§
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request