pub struct ClientBuilder { /* private fields */ }Expand description
Builds a Client with a chosen transaction timeout, retransmission schedule and
handler.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn with_rto(self, rto: Duration) -> Self
pub fn with_rto(self, rto: Duration) -> Self
Sets the initial RTO (RFC 8489 section 6.2.1; 500 ms by default, and the RFC asks for no less unless something else bounds the rate, as ICE’s pacing does).
It is the RTO of the first transaction and the floor of every later one: the RTO then
follows the server’s round-trip time upwards (see
with_rto_estimation).
Sourcepub fn with_rc(self, rc: u32) -> Self
pub fn with_rc(self, rc: u32) -> Self
Sets Rc, how many times a request is sent before the transaction fails (RFC 8489 section 6.2.1; 7 by default). Values below 1 are 1.
Sourcepub fn with_rm(self, rm: u32) -> Self
pub fn with_rm(self, rm: u32) -> Self
Sets Rm: the transaction fails Rm x RTO after the last request (RFC 8489 section 6.2.1; 16 by default).
Sourcepub fn with_ti(self, ti: Duration) -> Self
pub fn with_ti(self, ti: Duration) -> Self
Sets Ti, how long a request waits for its response over a reliable transport, where it is never retransmitted (RFC 8489 section 6.2.2; 39.5 s by default).
Sourcepub fn with_rto_estimation(self, on: bool) -> Self
pub fn with_rto_estimation(self, on: bool) -> Self
Turns the RFC 6298 computation of the RTO on or off (on by default).
On: a request answered without a retransmission gives a round-trip sample, and the RTO
of the next transaction is SRTT + 4 x RTTVAR, to 1 ms, never below the initial RTO.
It is kept for the server and dropped after ten minutes without a transaction.
Off: every transaction starts at the initial RTO.
Sourcepub fn with_max_outstanding_transactions(self, max: usize) -> Self
pub fn with_max_outstanding_transactions(self, max: usize) -> Self
Sets how many transactions may be outstanding at once (RFC 8489 section 6.2; 10 by
default). A request past the limit is refused by handle_write. 0 lifts the limit,
for a caller that limits its rate some other way.
Sourcepub fn with_path_mtu(self, mtu: usize) -> Self
pub fn with_path_mtu(self, mtu: usize) -> Self
Sets the path MTU to the server, when the caller knows it: a message over UDP then has to fit an IP packet of that size (RFC 8489 section 6.1).
Without it the RFC’s sizes for an unknown path MTU apply: an IP packet of 576 bytes
for IPv4 and 1280 bytes for IPv6, which is a STUN message of 548 or 1232 bytes.
handle_write refuses a larger one, so that it is never fragmented on the way. A
message that probes the path MTU is the one case where the RFC lets the rule go: set
usize::MAX for the client that sends it.
Sourcepub fn with_known_attributes(self, known: &[AttrType]) -> Self
pub fn with_known_attributes(self, known: &[AttrType]) -> Self
Sets the comprehension-required attributes the usage understands in a response:
STUN_ATTRIBUTES plus its own. A response that carries any other fails its
transaction with TransactionFailure::UnknownAttributes (RFC 8489 sections 6.3.3 and
6.3.4).
The default is STUN_ATTRIBUTES and RFC 3489’s SOURCE-ADDRESS, CHANGED-ADDRESS and
REFLECTED-FROM, which old servers still send in a Binding response.
Sourcepub fn with_response_integrity(
self,
key: impl Into<Vec<u8>>,
provider: Arc<dyn RTCCryptoProvider>,
) -> Self
pub fn with_response_integrity( self, key: impl Into<Vec<u8>>, provider: Arc<dyn RTCCryptoProvider>, ) -> Self
Requires every response to be authenticated with key (the short-term credential
mechanism, RFC 8489 section 9.1.4).
A response whose integrity attribute is absent or wrong is discarded as if it had
never arrived, so retransmissions continue; if the transaction then ends without an
authentic response, it ends with TransactionFailure::IntegrityViolation rather than
a timeout. Over a reliable transport such a response ends the transaction at once.
The message of StunEvent::Message then holds the authenticated attributes only.
The long-term mechanism has responses that are valid unsigned (401, 438): its caller
leaves this off and uses
LongTermCredentials::check_response.
Sourcepub fn with_timeout_rate(self, d: Duration) -> Self
👎Deprecated: has no effect: a sans-I/O client has no timer of its own, the caller’s handle_timeout calls set the resolution
pub fn with_timeout_rate(self, d: Duration) -> Self
has no effect: a sans-I/O client has no timer of its own, the caller’s handle_timeout calls set the resolution
with_timeout_rate sets RTO timer minimum resolution.
Sourcepub fn with_buffer_size(self, buffer_size: usize) -> Self
👎Deprecated: has no effect: the client buffers nothing of a fixed size
pub fn with_buffer_size(self, buffer_size: usize) -> Self
has no effect: the client buffers nothing of a fixed size
with_buffer_size sets buffer size.
Sourcepub fn with_no_retransmit(self) -> Self
pub fn with_no_retransmit(self) -> Self
Disables retransmissions: each request is sent once (Rc = 1) and its transaction fails Rm x RTO later.
A client built for TransportProtocol::TCP never retransmits and waits Ti, with or
without this (RFC 8489 section 6.2.2).
Sourcepub fn build(
self,
now: Instant,
local: SocketAddr,
remote: SocketAddr,
protocol: TransportProtocol,
) -> Result<Client>
pub fn build( self, now: Instant, local: SocketAddr, remote: SocketAddr, protocol: TransportProtocol, ) -> Result<Client>
Builds the client for the given local and remote addresses.
§Errors
Fails if the configured timings are inconsistent.