mirror of
https://github.com/nestriness/warp.git
synced 2025-12-15 03:15:41 +02:00
init
This commit is contained in:
31
moq-transport/src/message/subscribe_ok.rs
Normal file
31
moq-transport/src/message/subscribe_ok.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use crate::coding::{Decode, DecodeError, Encode, EncodeError, VarInt};
|
||||
|
||||
use crate::coding::{AsyncRead, AsyncWrite};
|
||||
use crate::setup::Extensions;
|
||||
|
||||
/// Sent by the publisher to accept a Subscribe.
|
||||
#[derive(Clone, Debug)]
|
||||
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.
|
||||
pub id: VarInt,
|
||||
|
||||
/// The subscription will expire in this many milliseconds.
|
||||
pub expires: VarInt,
|
||||
}
|
||||
|
||||
impl SubscribeOk {
|
||||
pub async fn decode<R: AsyncRead>(r: &mut R, _ext: &Extensions) -> Result<Self, DecodeError> {
|
||||
let id = VarInt::decode(r).await?;
|
||||
let expires = VarInt::decode(r).await?;
|
||||
Ok(Self { id, expires })
|
||||
}
|
||||
}
|
||||
|
||||
impl SubscribeOk {
|
||||
pub async fn encode<W: AsyncWrite>(&self, w: &mut W, _ext: &Extensions) -> Result<(), EncodeError> {
|
||||
self.id.encode(w).await?;
|
||||
self.expires.encode(w).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user