moq-rs/moq-transport/src/message/announce_stop.rs
kixelated 88542e266c
Major moq-transport API simplification (#68)
Exponentially easier to use moq-transport as there's no message handling required. This is a BREAKING CHANGE.
2023-09-15 12:06:28 -07:00

25 lines
607 B
Rust

use crate::coding::{decode_string, encode_string, DecodeError, EncodeError};
use crate::coding::{AsyncRead, AsyncWrite};
/// Sent by the publisher to terminate an Announce.
#[derive(Clone, Debug)]
pub struct AnnounceStop {
// Echo back the namespace that was reset
pub namespace: String,
}
impl AnnounceStop {
pub async fn decode<R: AsyncRead>(r: &mut R) -> Result<Self, DecodeError> {
let namespace = decode_string(r).await?;
Ok(Self { namespace })
}
pub async fn encode<W: AsyncWrite>(&self, w: &mut W) -> Result<(), EncodeError> {
encode_string(&self.namespace, w).await?;
Ok(())
}
}