#[non_exhaustive]pub enum ProtocolControl {
SetChunkSize(u32),
Abort {
chunk_stream_id: u32,
},
Acknowledgement(u32),
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(u32)
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(u32)
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) -> u8
pub fn message_type_id(&self) -> u8
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: u8,
payload: &[u8],
) -> Result<Option<Self>, RtmpError>
pub fn from_payload( message_type_id: u8, 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_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
Source§fn clone(&self) -> ProtocolControl
fn clone(&self) -> ProtocolControl
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl 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.