#[non_exhaustive]pub enum ProtocolControl {
SetChunkSize(ChunkSize),
Abort {
chunk_stream_id: u32,
},
Acknowledgement(SequenceNumber),
WindowAckSize(u32),
SetPeerBandwidth {
ack_window_size: u32,
limit_type: LimitType,
},
}Expand description
A Chunk-Stream-layer protocol control message (§4, spec §5.4):
message type ids 1, 2, 3, 5, 6. MUST use message stream id 0
and chunk stream id 2 (CONTROL_MESSAGE_STREAM_ID /
CONTROL_CHUNK_STREAM_ID); effective immediately on receipt.
#[non_exhaustive]: §4’s protocol control catalogue is closed today,
but this mirrors UserControl/crate::amf0::Amf0Value so a future
addition never breaks an existing match.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SetChunkSize(ChunkSize)
Set Chunk Size (§5.4.1): the new maximum chunk size (1..=0x7FFF_FFFF).
Abort
Abort Message (§5.4.2): discard any partially-received message on this chunk stream id.
Acknowledgement(SequenceNumber)
Acknowledgement (§5.4.3): total bytes received so far.
WindowAckSize(u32)
Window Acknowledgement Size (§5.4.4): the sender’s advertised window size.
SetPeerBandwidth
Set Peer Bandwidth (§5.4.5): limit the peer’s output bandwidth.
Implementations§
Source§impl ProtocolControl
impl ProtocolControl
Sourcepub fn message_type_id(&self) -> MessageTypeId
pub fn message_type_id(&self) -> MessageTypeId
This variant’s message type id (§6/§7.1).
Sourcepub fn from_message(message: &Message) -> Result<Option<Self>, RtmpError>
pub fn from_message(message: &Message) -> Result<Option<Self>, RtmpError>
Interpret an already-reassembled Message as a protocol control
message, dispatching on message.message_type_id.
Returns Ok(None) if message.message_type_id is not one of the
protocol control ids (1, 2, 3, 5, 6) — the caller should
then dispatch it elsewhere (user control, audio/video, command, …).
§Errors
RtmpError::BufferTooShort if the payload is shorter than the
message type requires; RtmpError::Malformed if a field violates
its wire constraint (reserved bit set, out-of-range limit type).
Sourcepub fn from_payload(
message_type_id: MessageTypeId,
payload: &[u8],
) -> Result<Option<Self>, RtmpError>
pub fn from_payload( message_type_id: MessageTypeId, payload: &[u8], ) -> Result<Option<Self>, RtmpError>
Parse a protocol control payload given its message type id. Not a
Parse impl: unlike every other wire type in this crate, a
protocol control payload alone is ambiguous (e.g. a bare 4-byte
payload is SetChunkSize, Abort, Acknowledgement, or
WindowAckSize depending on the message type id carried alongside
it in the Message header) — the type id is required context.
§Errors
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
The message payload, built without a fallible length check: the
result length is the type’s own Serialize::serialized_len.
Sourcepub fn to_message(&self) -> Message
pub fn to_message(&self) -> Message
Wrap this protocol control message in a Message ready to hand to
crate::chunk::ChunkWriter — chunk stream id
CONTROL_CHUNK_STREAM_ID, message stream id
CONTROL_MESSAGE_STREAM_ID, timestamp 0 (protocol control
messages take effect immediately; timestamps are not meaningful).
Trait Implementations§
Source§impl Clone for ProtocolControl
impl Clone for ProtocolControl
impl Copy for ProtocolControl
Source§impl Debug for ProtocolControl
impl Debug for ProtocolControl
Source§impl Display for ProtocolControl
impl Display for ProtocolControl
impl Eq for ProtocolControl
Source§impl PartialEq for ProtocolControl
impl PartialEq for ProtocolControl
Source§impl Serialize for ProtocolControl
impl Serialize for ProtocolControl
Source§type Error = RtmpError
type Error = RtmpError
Parse impl, but need not be).Source§fn serialized_len(&self) -> usize
fn serialized_len(&self) -> usize
serialize_into will write.Source§fn serialize_into(&self, buf: &mut [u8]) -> Result<usize, RtmpError>
fn serialize_into(&self, buf: &mut [u8]) -> Result<usize, RtmpError>
buf. Returns the number of bytes
written (always equal to serialized_len()).Source§fn try_to_bytes(&self) -> Result<Vec<u8>, Self::Error>
fn try_to_bytes(&self) -> Result<Vec<u8>, Self::Error>
Vec and serialize into it, returning the serializer’s error instead of
panicking. This is the only
allocate-and-serialize entry point: there is deliberately no panicking
to_bytes (hand-built values, or values assembled from damaged wire data,
can violate a wire constraint, so the error must reach the caller).