2023-08-15 17:20:03 +00:00
|
|
|
use crate::coding::{DecodeError, EncodeError, VarInt};
|
|
|
|
|
2023-09-15 19:06:28 +00:00
|
|
|
use crate::coding::{AsyncRead, AsyncWrite};
|
2023-08-15 17:20:03 +00:00
|
|
|
|
2023-09-15 19:06:28 +00:00
|
|
|
/// Sent by the publisher to accept a Subscribe.
|
2023-08-29 04:59:30 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2023-08-15 17:20:03 +00:00
|
|
|
pub struct SubscribeOk {
|
|
|
|
// NOTE: No full track name because of this proposal: https://github.com/moq-wg/moq-transport/issues/209
|
|
|
|
|
|
|
|
// The ID for this track.
|
2023-09-15 19:06:28 +00:00
|
|
|
pub id: VarInt,
|
2023-08-15 17:20:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl SubscribeOk {
|
2023-09-15 19:06:28 +00:00
|
|
|
pub async fn decode<R: AsyncRead>(r: &mut R) -> Result<Self, DecodeError> {
|
|
|
|
let id = VarInt::decode(r).await?;
|
|
|
|
Ok(Self { id })
|
2023-08-15 17:20:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl SubscribeOk {
|
2023-09-15 19:06:28 +00:00
|
|
|
pub async fn encode<W: AsyncWrite>(&self, w: &mut W) -> Result<(), EncodeError> {
|
|
|
|
self.id.encode(w).await?;
|
2023-08-15 17:20:03 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|