hang/catalog/
reference.rs1use super::{AudioConfig, BinaryConfig, JsonConfig, TextConfig, VideoConfig};
2
3pub trait Reference {
9 fn broadcast(&self) -> Option<&moq_net::path::Relative>;
11
12 fn track<'a>(&'a self, id: &'a str) -> &'a str;
14}
15
16macro_rules! reference {
17 ($($config:ty),*) => {$(
18 impl Reference for $config {
19 fn broadcast(&self) -> Option<&moq_net::path::Relative> {
20 self.broadcast.as_ref()
21 }
22
23 fn track<'a>(&'a self, id: &'a str) -> &'a str {
24 self.track.as_deref().unwrap_or(id)
25 }
26 }
27 )*};
28}
29
30reference!(VideoConfig, AudioConfig, TextConfig, JsonConfig, BinaryConfig);
31
32pub(crate) fn renamed_version(config: &impl Reference, id: &str) -> Option<u64> {
35 (config.track(id) != id).then_some(4)
36}