Skip to content

Commit

Permalink
moq-transport: MaxSubscribeId message coding
Browse files Browse the repository at this point in the history
draft-06

encode/decode support for MaxSubscribeId

MAX_SUBSCRIBE_ID control message

- [PR 491](moq-wg/moq-transport#491)
- [PR 528](moq-wg/moq-transport#528)
- [§6.16](https://www.ietf.org/archive/id/draft-ietf-moq-transport-06.html#section-6.16)

Just parsing for the control message so far, not wired up anywhere yet,
will need error codes
  • Loading branch information
englishm committed Nov 21, 2024
1 parent 6d9e500 commit 30e21d2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions moq-transport/src/message/max_subscribe_id.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use crate::coding::{Decode, DecodeError, Encode, EncodeError};

/// Sent by the publisher to update the max allowed subscription ID for the session.
#[derive(Clone, Debug)]
pub struct MaxSubscribeId {
/// The max allowed subscription ID
pub id: u64,
}

impl Decode for MaxSubscribeId {
fn decode<R: bytes::Buf>(r: &mut R) -> Result<Self, DecodeError> {
let id = u64::decode(r)?;

Ok(Self { id })
}
}

impl Encode for MaxSubscribeId {
fn encode<W: bytes::BufMut>(&self, w: &mut W) -> Result<(), EncodeError> {
self.id.encode(w)?;

Ok(())
}
}
3 changes: 3 additions & 0 deletions moq-transport/src/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ mod announce_ok;
mod filter_type;
mod go_away;
mod group_order;
mod max_subscribe_id;
mod publisher;
mod subscribe;
mod subscribe_done;
Expand All @@ -62,6 +63,7 @@ pub use announce_ok::*;
pub use filter_type::*;
pub use go_away::*;
pub use group_order::*;
pub use max_subscribe_id::*;
pub use publisher::*;
pub use subscribe::*;
pub use subscribe_done::*;
Expand Down Expand Up @@ -182,6 +184,7 @@ message_types! {
SubscribeOk = 0x4,
SubscribeError = 0x5,
SubscribeDone = 0xb,
MaxSubscribeId = 0x15,

// ANNOUNCE family, sent by publisher
Announce = 0x6,
Expand Down

0 comments on commit 30e21d2

Please sign in to comment.