pub struct TaggedMessage {
pub now: Instant,
pub message: Message,
}Expand description
A Message together with the instant the caller is sending it at.
Rin is a TaggedBytesMut, which carries a timestamp; without this the write channel
would not, and handle_write would have to ask the clock for one. A STUN client’s first
action is typically a write before any read, so a retained instant is not an option here —
it would still be the construction seed.
Fields§
§now: InstantWhen the caller is sending this message.
message: MessageThe STUN message to send.
Trait Implementations§
Source§impl Protocol<TransportMessage<BytesMut>, TaggedMessage, ()> for Client
impl Protocol<TransportMessage<BytesMut>, TaggedMessage, ()> for Client
Source§fn handle_read(&mut self, msg: TaggedBytesMut) -> Result<()>
fn handle_read(&mut self, msg: TaggedBytesMut) -> Result<()>
Takes a datagram (or one framed message of a stream) from the network.
What is not the response to an outstanding request is dropped without an event (RFC 8489 section 6.3): a message from another address than the server’s, a request or an indication, a response with an unknown transaction id or of another method, and a message whose FINGERPRINT does not match.
§Errors
Fails when the server’s datagram is not a STUN message.
Source§fn handle_write(&mut self, msg: TaggedMessage) -> Result<()>
fn handle_write(&mut self, msg: TaggedMessage) -> Result<()>
Sends a message to the server.
A request starts a transaction, which ends with one event: the response, a timeout or a failure. An indication is sent and forgotten: it has no response and no timeout (RFC 8489 section 6.3.2).
§Errors
Fails when the client is closed, when the message is larger than the path MTU allows
over UDP (ErrPacketTooBig; RFC 8489 section 6.1,
with_path_mtu), when a request reuses the
transaction id of an outstanding one, and when the limit of outstanding transactions
is reached (RFC 8489 section 6.2;
with_max_outstanding_transactions).
Source§fn poll_write(&mut self) -> Option<Self::Wout>
fn poll_write(&mut self) -> Option<Self::Wout>
Returns packets to transmit
It should be polled for transmit after:
- the application performed some I/O
- a call was made to
handle_read - a call was made to
handle_write - a call was made to
handle_timeout
Source§fn poll_timeout(&mut self) -> Option<Self::Time>
fn poll_timeout(&mut self) -> Option<Self::Time>
When handle_timeout is next due: the earliest retransmission or transaction end.
Source§fn handle_timeout(&mut self, now: Instant) -> Result<()>
fn handle_timeout(&mut self, now: Instant) -> Result<()>
Advances time: every request whose interval has passed (deadline <= now) is sent
again, or, after its last transmission, its transaction ends with
StunEvent::TransactionTimeOut.