pub struct Request { /* private fields */ }Expand description
A connection request by the remote endpoint.
Dropping the request rejects it.
Implementations§
Source§impl Request
impl Request
Sourcepub fn remote_port(&self) -> u32
pub fn remote_port(&self) -> u32
The remote port number.
Sourcepub fn id(&self) -> u32
pub fn id(&self) -> u32
The remotely provided id.
If no id was provided, this returns the remote port.
Sourcepub fn is_wait(&self) -> bool
pub fn is_wait(&self) -> bool
Indicates whether the handler of the request should wait for a local port to become available, if all are currently in use.
Sourcepub fn is_pre_connected(&self) -> bool
pub fn is_pre_connected(&self) -> bool
Returns whether the remote endpoint provisionally opened this channel.
A pre-connected channel may already carry data even though this request has not yet been accepted. Rejecting the request also rejects that provisional channel.
Sourcepub async fn accept_tentatively(
self,
) -> Result<(Sender, Receiver, AcceptGuard), TentativeAcceptError>
pub async fn accept_tentatively( self, ) -> Result<(Sender, Receiver, AcceptGuard), TentativeAcceptError>
Tentatively accepts the request, so that it can still be rejected afterwards.
This consumes the request and returns the sender and receiver for the new bidirectional port together with a guard that allows rejecting the connection afterwards. Dropping the guard confirms the connection.
Use this when the decision whether to serve the channel depends on a result that is not available yet, for example the response of another endpoint the channel is forwarded to. Data can be exchanged over the port while the decision is pending.
This is only possible for a pre-connected request, since
only its requester is prepared to be told about a rejection after the channel has
been established. Otherwise TentativeAcceptError::NotPreConnected is returned
and the request is rejected.