Expand description
Shared types and utilities for the Sans-I/O WebRTC stack.
This crate holds what every other crate in the rtc stack needs:
the common Error type, the Marshal/Unmarshal
traits that every protocol codec implements, and the transport plumbing that carries
bytes between the network and a protocol state machine.
§Key types
TransportContext/TransportMessage— a datagram plus the 4-tuple and protocol it arrived on or should be sent on. Every layer in the stack passes these around instead of touching sockets.marshal—Marshal,UnmarshalandMarshalSize, the wire-format traits shared by STUN, RTP, RTCP, SDP, DTLS and SCTP.error— the crate-wideErrorenum andResultalias, re-exported by the higher-level crates so callers import from one place.crypto,replay_detector— primitives shared by DTLS and SRTP.tcp_framing— RFC 4571 length-prefixed framing, for ICE-TCP candidates.ifaces— local interface enumeration used during ICE candidate gathering.
§Feature flags
crypto, ifaces, marshal and replay are all enabled by default; each gates the
correspondingly named module so that dependents can compile only what they use.
§Example
Every protocol codec in the stack implements the same three traits, so encoding and decoding look the same whichever layer you are at:
use bytes::Bytes;
use rtc_shared::marshal::{Marshal, MarshalSize, Unmarshal};
// Size the buffer, encode into it, then decode the result back.
let n = value.marshal_size();
let encoded = value.marshal()?;
assert_eq!(encoded.len(), n);
let mut buf = Bytes::from(encoded.to_vec());
assert_eq!(T::unmarshal(&mut buf)?, value);Most applications do not depend on this crate directly — the rtc
crate re-exports what it needs as rtc::shared.
Modules§
- crypto
- Cryptographic primitives shared by DTLS and SRTP, including DTLS-SRTP keying-material export.
- error
- The crate-wide error type shared by every protocol in the stack. The error type shared across the stack.
- ifaces
- Local network interface enumeration, used to gather ICE host candidates.
- marshal
- The wire-format traits every protocol codec in the stack implements.
- replay_
detector - Replay protection for sequence-numbered packets, as DTLS and SRTP require.
- serde
serdehelpers for types that have no natural serialized form, such asstd::time::Instant.- tcp_
framing - TCP framing utilities for ICE over TCP (RFC 4571/RFC 6544).
- time
- Conversions between monotonic, Unix and NTP time. Monotonic, Unix and NTP time.
- util
- Small shared helpers: packet demultiplexing predicates and random-string generation. Shared helpers: packet demultiplexing and random strings.
Structs§
- Five
Tuple - Five Tuple consists of local address, peer address and protocol
- Four
Tuple - Four Tuple consists of local address and peer address
- Transport
Context - Transport Context with local address, peer address, ECN, protocol, etc.
- Transport
Message - A generic transmit with TransportContext
Enums§
- EcnCodepoint
- Explicit congestion notification codepoint
- Transport
Protocol - Type of transport protocol, either UDP or TCP
Type Aliases§
- Tagged
Bytes Mut - BytesMut type transmit with TransportContext