pub struct PathRelative<'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),
PathRelative may contain .. segments to walk up 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).
PathRelative 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 . segments are stripped (treated as no-ops, matching
POSIX). .. is preserved and is interpreted at resolve time.
§Examples
use moq_net::{Path, PathRelative};
let rel = PathRelative::new("../source");
assert_eq!(Path::new("a/b").resolve(&rel).as_str(), "a/source");
// `.` segments are stripped on creation.
assert_eq!(PathRelative::new("./a/./b").as_str(), "a/b");Implementations§
Source§impl<'a> PathRelative<'a>
impl<'a> PathRelative<'a>
Sourcepub fn new(s: &'a str) -> Self
pub fn new(s: &'a str) -> Self
Create a new PathRelative from a string slice.
Leading and trailing slashes are trimmed, consecutive internal slashes collapse to one,
and . segments are stripped. See the type-level doc for the full normalization rules.
Sourcepub fn empty() -> PathRelative<'static>
pub fn empty() -> PathRelative<'static>
The empty relative path, which resolves to the base path itself.
Sourcepub fn to_owned(&self) -> PathRelativeOwned
pub fn to_owned(&self) -> PathRelativeOwned
Copy into an owned version with a 'static lifetime.
Sourcepub fn into_owned(self) -> PathRelativeOwned
pub fn into_owned(self) -> PathRelativeOwned
Convert into an owned version with a 'static lifetime.
Sourcepub fn borrow(&'a self) -> PathRelative<'a>
pub fn borrow(&'a self) -> PathRelative<'a>
Reborrow without copying.
Trait Implementations§
Source§impl AsRef<str> for PathRelative<'_>
impl AsRef<str> for PathRelative<'_>
Source§impl<'a> Clone for PathRelative<'a>
impl<'a> Clone for PathRelative<'a>
Source§fn clone(&self) -> PathRelative<'a>
fn clone(&self) -> PathRelative<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more