T1.2.1: Add rustdoc on MediaType variants and methods

This commit is contained in:
Siavash Sameni
2026-05-11 11:33:42 +04:00
parent 6eb94f079d
commit 6385b93391
3 changed files with 79 additions and 4 deletions

View File

@@ -1,20 +1,26 @@
use serde::{Deserialize, Serialize};
/// Media stream type carried in a v2 [`MediaHeader`](crate::MediaHeaderV2).
/// Media stream type carried in a v2 [`MediaHeaderV2`](crate::MediaHeaderV2).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u8)]
pub enum MediaType {
/// Encoded speech / music (Opus, Codec2, ComfortNoise).
Audio = 0,
/// Encoded video access unit (H.264, H.265, AV1; PRD-video-multicodec).
Video = 1,
/// Opaque payload not interpreted by the relay (reserved).
Data = 2,
/// In-band control message carried on the media plane (reserved).
Control = 3,
}
impl MediaType {
/// Encode to the wire byte representation (`self as u8`).
pub const fn to_wire(self) -> u8 {
self as u8
}
/// Decode from a wire byte. Returns `None` for values outside 0..=3.
pub const fn from_wire(v: u8) -> Option<Self> {
match v {
0 => Some(Self::Audio),