pub struct Relative<'a>(/* private fields */);Expand description
A relative broadcast path, used to reference one broadcast from another broadcast’s content.
Unlike Path (which is a complete reference within the broadcast namespace),
Relative may contain . and .. segments to walk the namespace and is meaningful
only when resolved against a base Path via Path::resolve. The hang catalog uses it
to point a rendition at a track published in a sibling broadcast (e.g. ./source).
Relative has no Encode/Decode impl, so it never appears in announce/subscribe
frames. It does serialize via serde for off-wire use (e.g. as a field inside a catalog
JSON payload, which itself travels as a track).
Normalization on creation: leading/trailing slashes are trimmed, consecutive internal
slashes collapse to one, and redundant . segments are stripped. A reference made only
of . segments normalizes to . rather than empty because . resolves to the base’s
parent while empty resolves to the base itself. .. is preserved for resolve time.
§Examples
use moq_net::{Path, path::Relative};
let rel = Relative::new("./source");
assert_eq!(Path::new("a/b").resolve(&rel).as_str(), "a/source");
// Redundant `.` segments are stripped on creation.
assert_eq!(Relative::new("./a/./b").as_str(), "a/b");
assert_eq!(Relative::new(".").as_str(), ".");Implementations§
Source§impl<'a> Relative<'a>
impl<'a> Relative<'a>
Sourcepub fn new(s: &'a str) -> Self
pub fn new(s: &'a str) -> Self
Create a new Relative from a string slice.
Leading and trailing slashes are trimmed, consecutive internal slashes collapse to one,
and redundant . segments are stripped. See the type-level doc for the full rules.
Sourcepub fn empty() -> Relative<'static>
pub fn empty() -> Relative<'static>
The empty relative path, which resolves to the base path itself.
Sourcepub fn to_owned(&self) -> RelativeOwned
pub fn to_owned(&self) -> RelativeOwned
Copy into an owned version with a 'static lifetime.
Sourcepub fn into_owned(self) -> RelativeOwned
pub fn into_owned(self) -> RelativeOwned
Convert into an owned version with a 'static lifetime.