pub struct Template { /* private fields */ }Expand description
A parsed resource template.
Implementations§
Source§impl Template
impl Template
pub fn parse(raw: &str) -> Result<Self, TemplateError>
pub fn as_str(&self) -> &str
pub fn segments(&self) -> &[Segment]
Sourcepub fn params(&self) -> impl Iterator<Item = (&str, bool)>
pub fn params(&self) -> impl Iterator<Item = (&str, bool)>
Parameter names, in order, with whether each is a rest parameter.
pub fn has_params(&self) -> bool
Sourcepub fn shape(&self) -> String
pub fn shape(&self) -> String
The template’s shape: literal chunks kept, parameters erased. Two templates under one kind token may not share a shape (r3.3 D1).
Sourcepub fn build(&self, values: &Bindings) -> Result<Vec<String>, String>
pub fn build(&self, values: &Bindings) -> Result<Vec<String>, String>
Builds the resource chunks from raw (unslugged) values. Every value is slugged; a rest parameter takes one or more values.
Sourcepub fn matches(&self, chunks: &[&str]) -> Option<Bindings>
pub fn matches(&self, chunks: &[&str]) -> Option<Bindings>
Matches resource chunks against this template, returning the
unslugged values. None when it does not match, or when a value is
not a canonical slug.
Sourcepub fn overlaps(&self, other: &Template) -> bool
pub fn overlaps(&self, other: &Template) -> bool
Whether some resource path matches both templates.
Sourcepub fn precedence(&self, other: &Template) -> Ordering
pub fn precedence(&self, other: &Template) -> Ordering
Precedence between two templates that both match a key: Greater
means self wins (it is more literal at the first differing
segment, r3.3 D1).
Trait Implementations§
impl Eq for Template
impl StructuralPartialEq for Template
Auto Trait Implementations§
impl Forget for Template
impl Freeze for Template
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnsafeUnpin for Template
impl UnwindSafe for Template
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more