pub struct Relative(/* 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).
It is spelled like a Path, so a leading, trailing, or doubled / or a lone \ is
refused rather than collapsed, and an escaped / never splits a segment. Redundant . segments are stripped on creation. 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::from_static("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(), ".");
// An empty segment is refused, not collapsed.
assert!(Relative::new("./a/").is_err());Implementations§
Source§impl Relative
impl Relative
Sourcepub fn new(s: &str) -> Result<Self, Error>
pub fn new(s: &str) -> Result<Self, Error>
Create a new Relative from a string slice.
Fails like Path::new on a string that is not a valid path, and strips redundant
. segments from one that is. See the type-level doc for the full rules.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Relative
impl<'de> Deserialize<'de> for Relative
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl Eq for Relative
impl StructuralPartialEq for Relative
Auto Trait Implementations§
impl Freeze for Relative
impl RefUnwindSafe for Relative
impl Send for Relative
impl Sync for Relative
impl Unpin for Relative
impl UnsafeUnpin for Relative
impl UnwindSafe for Relative
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.