1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-FileCopyrightText: 2024-2026 Cloudflare Inc., Luke Curley, Mike English and contributors
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::coding::{Decode, DecodeError, Encode, EncodeError, ReasonPhrase};
// TODO SLG - The next draft is going to merge all these error messages to a
// common RequestError message, so we won't do a lot of work on these
// existing messages. We should add an enum for all the various error codes.
/// Sent by the subscriber to reject an Announce.
#[derive(Clone, Debug)]
pub struct TrackStatusError {
pub id: u64,
// An error code.
pub error_code: u64,
// An optional, human-readable reason.
pub reason_phrase: ReasonPhrase,
}
impl Decode for TrackStatusError {
fn decode<R: bytes::Buf>(r: &mut R) -> Result<Self, DecodeError> {
let id = u64::decode(r)?;
let error_code = u64::decode(r)?;
let reason_phrase = ReasonPhrase::decode(r)?;
Ok(Self {
id,
error_code,
reason_phrase,
})
}
}
impl Encode for TrackStatusError {
fn encode<W: bytes::BufMut>(&self, w: &mut W) -> Result<(), EncodeError> {
self.id.encode(w)?;
self.error_code.encode(w)?;
self.reason_phrase.encode(w)?;
Ok(())
}
}