Skip to main content

ProtocolControl

Enum ProtocolControl 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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.

Fields

§chunk_stream_id: u32

The chunk stream id whose in-progress message should be discarded.

§

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.

Fields

§ack_window_size: u32

The acknowledgement window size to limit the peer to.

§limit_type: LimitType

How strictly the peer should observe the limit.

Implementations§

Source§

impl ProtocolControl

Source

pub fn name(&self) -> &'static str

The spec token for this protocol control message.

Source

pub fn message_type_id(&self) -> MessageTypeId

This variant’s message type id (§6/§7.1).

Source

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).

Source

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

See ProtocolControl::from_message.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ProtocolControl

Source§

impl Debug for ProtocolControl

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ProtocolControl

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ProtocolControl

Source§

impl PartialEq for ProtocolControl

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ProtocolControl

Source§

type Error = RtmpError

The error type this implementer returns (usually the same as the corresponding Parse impl, but need not be).
Source§

fn serialized_len(&self) -> usize

Number of bytes serialize_into will write.
Source§

fn serialize_into(&self, buf: &mut [u8]) -> Result<usize, RtmpError>

Write the serialised form into buf. Returns the number of bytes written (always equal to serialized_len()).
Source§

fn try_to_bytes(&self) -> Result<Vec<u8>, Self::Error>

Allocate a 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).
Source§

fn serialize_append(&self, out: &mut Vec<u8>) -> Result<usize, Self::Error>

Append the serialised form to out, returning the number of bytes appended. out is left unchanged when the serializer fails.
Source§

impl StructuralPartialEq for ProtocolControl

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.