Struct UriTemplateStr
struct UriTemplateStr { ... }
A borrowed slice of a URI template.
URI Template is defined by RFC 6570.
Note that "URI Template" can also be used for IRI.
Valid values
This type can have a URI template string.
Applied errata
Errata ID 6937 is applied, so single quotes are allowed to appear in an URI template.
# use Error;
use UriTemplateStr;
let template = new?;
# Ok::
Implementations
impl UriTemplateStr
fn new(s: &str) -> Result<&Self, Error>Creates a new string.
Examples
# use Error; use UriTemplateStr; let template = new?; # Ok::unsafe fn new_unchecked(s: &str) -> &SelfCreates a new string without validation.
This does not validate the given string, so it is caller's responsibility to ensure the given string is valid.
Safety
The given string must be syntactically valid as
Selftype. If not, any use of the returned value or the call of this function itself may result in undefined behavior.fn as_str(self: &Self) -> &strReturns the template as a plain
&str.Examples
# use Error; use UriTemplateStr; let template = new?; assert_eq!; # Ok::fn len(self: &Self) -> usizeReturns the template string length.
Examples
# use Error; use UriTemplateStr; let template = new?; assert_eq!; # Ok::fn is_empty(self: &Self) -> boolReturns whether the string is empty.
Examples
# use Error; use UriTemplateStr; let template = new?; assert!; let empty = new?; assert!; # Ok::
impl UriTemplateStr
fn expand<'a, S: Spec, C: Context>(self: &'a Self, context: &'a C) -> Result<Expanded<'a, S, C>, Error>Expands the template with the given context.
Examples
# use Error; # # Ok::You can control allowed characters in the output by changing spec type.
# use Error; # # Ok::fn expand_dynamic<S: Spec, W: fmt::Write, C: DynamicContext>(self: &Self, writer: &mut W, context: &mut C) -> Result<(), Error>Expands the template with the given dynamic context.
If you need the allocated
String, use[expand_dynamic_to_string]Self::expand_dynamic_to_string.See the documentation for
DynamicContextfor usage.fn expand_dynamic_to_string<S: Spec, C: DynamicContext>(self: &Self, context: &mut C) -> Result<String, Error>Expands the template into a string, with the given dynamic context.
This is basically [
expand_dynamic]Self::expand_dynamicmethod that returns an owned string instead of writing to the given writer.See the documentation for
DynamicContextfor usage.Examples
# # extern crate alloc; # use Error; # # Ok::fn variables(self: &Self) -> UriTemplateVariables<'_>Returns an iterator of variables in the template.
Examples
# use Error; use UriTemplateStr; let template = new?; let mut vars = template.variables; assert_eq!; assert_eq!; assert_eq!; assert_eq!; # Ok::
impl AsRef for UriTemplateStr
fn as_ref(self: &Self) -> &UriTemplateStr
impl AsRef for UriTemplateStr
fn as_ref(self: &Self) -> &str
impl Debug for UriTemplateStr
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Display for UriTemplateStr
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for UriTemplateStr
impl Freeze for UriTemplateStr
impl Hash for UriTemplateStr
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl Ord for UriTemplateStr
fn cmp(self: &Self, other: &UriTemplateStr) -> Ordering
impl PartialEq for UriTemplateStr
fn eq(self: &Self, o: &Cow<'_, str>) -> bool
impl PartialEq for UriTemplateStr
fn eq(self: &Self, o: &&str) -> bool
impl PartialEq for UriTemplateStr
fn eq(self: &Self, o: &str) -> bool
impl PartialEq for UriTemplateStr
fn eq(self: &Self, other: &UriTemplateStr) -> bool
impl PartialOrd for UriTemplateStr
fn partial_cmp(self: &Self, other: &UriTemplateStr) -> Option<Ordering>
impl PartialOrd for UriTemplateStr
fn partial_cmp(self: &Self, o: &Cow<'_, str>) -> Option<Ordering>
impl PartialOrd for UriTemplateStr
fn partial_cmp(self: &Self, o: &&str) -> Option<Ordering>
impl PartialOrd for UriTemplateStr
fn partial_cmp(self: &Self, o: &str) -> Option<Ordering>
impl RefUnwindSafe for UriTemplateStr
impl Send for UriTemplateStr
impl Sized for UriTemplateStr
impl StructuralPartialEq for UriTemplateStr
impl Sync for UriTemplateStr
impl ToOwned for UriTemplateStr
fn to_owned(self: &Self) -> <Self as >::Owned
impl Unpin for UriTemplateStr
impl UnsafeUnpin for UriTemplateStr
impl UnwindSafe for UriTemplateStr
impl<T> Any for UriTemplateStr
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for UriTemplateStr
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for UriTemplateStr
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> ToString for UriTemplateStr
fn to_string(self: &Self) -> String