pub struct Sender<T: SnapTunToken> { /* private fields */ }Expand description
Sender can be used to send packets to the client. It is returned by Server::accept_with_timeout.
Sender offers a synchronous and an asychronous API to send packets to the client.
Implementations§
Source§impl<T: SnapTunToken> Sender<T>
impl<T: SnapTunToken> Sender<T>
Sourcepub fn assigned_addresses(&self) -> Vec<EndhostAddr>
pub fn assigned_addresses(&self) -> Vec<EndhostAddr>
Returns the addresses assigned to this sender.
Sourcepub fn assigned_socket_addr(&self) -> Option<SocketAddr>
pub fn assigned_socket_addr(&self) -> Option<SocketAddr>
Returns the endhost socket address assigned to the endhost.
Sourcepub fn remote_underlay_address(&self) -> SocketAddr
pub fn remote_underlay_address(&self) -> SocketAddr
Returns the remote address of the underlying QUIC connection.
Sourcepub fn send(&self, pkt: Bytes) -> Result<(), SendPacketError<T>>
pub fn send(&self, pkt: Bytes) -> Result<(), SendPacketError<T>>
Send a packet to the client. The packet needs to fit entirely into a QUIC datagram.
§Errors
The function returns an error if either the connection is in an erroneous state (non-recoverable), or the address assignment has changed. In the latter case, SendPacketError::NewAssignedAddress is returned with a new Sender object that is assigned the new address. The old object will return a SendPacketError::ConnectionClosed error.
Sourcepub async fn send_wait(&self, pkt: Bytes) -> Result<(), SendPacketError<T>>
pub async fn send_wait(&self, pkt: Bytes) -> Result<(), SendPacketError<T>>
Send a packet to the client. The packet needs to fit entirely into a QUIC datagram.
Unlike Self::send, this method will wait for buffer space during congestion conditions, which effectively prioritizes old datagrams over new datagrams.
Sourcepub fn close(&self, error_code: SnaptunConnErrors, reason: &[u8])
pub fn close(&self, error_code: SnaptunConnErrors, reason: &[u8])
Immediately closes the underlying connection with the given code and reason.
All other methods on this Sender will return ConnectionClosed after this is called.
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for Sender<T>
impl<T> !RefUnwindSafe for Sender<T>
impl<T> Send for Sender<T>
impl<T> Sync for Sender<T>
impl<T> Unpin for Sender<T>
impl<T> !UnwindSafe for Sender<T>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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