pub struct UriTemplateLabel(/* private fields */);Expand description
A label for the URL template that can be attached to HTTP requests as an extension.
This type is a workaround for cases where a templated URI cannot be used.
When possible, prefer using templated URIs via the #[templated] macro from
templated_uri, as they provide better type safety and automatic template extraction.
When both a templated URI and a UriTemplateLabel are present on a request,
the explicit UriTemplateLabel takes precedence.
§Example
use http_extensions::{HttpRequestBuilder, UriTemplateLabel};
let request = HttpRequestBuilder::new_fake()
.get("https://example.com/api/users/123")
.extension(UriTemplateLabel::new("/api/users/{id}"))
.build()
.unwrap();Implementations§
Source§impl UriTemplateLabel
impl UriTemplateLabel
Sourcepub fn new(label: impl Into<Cow<'static, str>>) -> Self
pub fn new(label: impl Into<Cow<'static, str>>) -> Self
Creates a new UriTemplateLabel from any type that can be converted to a Cow<'static, str>.
This accepts static strings, owned Strings, or Cow<'static, str> directly.
Sourcepub const fn new_static(label: &'static str) -> Self
pub const fn new_static(label: &'static str) -> Self
Creates a new UriTemplateLabel from a static string.
This is a const function that can be used in const contexts.
Trait Implementations§
Source§impl AsRef<str> for UriTemplateLabel
impl AsRef<str> for UriTemplateLabel
Source§impl Clone for UriTemplateLabel
impl Clone for UriTemplateLabel
Source§fn clone(&self) -> UriTemplateLabel
fn clone(&self) -> UriTemplateLabel
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UriTemplateLabel
impl Debug for UriTemplateLabel
Source§impl Display for UriTemplateLabel
impl Display for UriTemplateLabel
Source§impl From<&'static str> for UriTemplateLabel
impl From<&'static str> for UriTemplateLabel
Source§impl From<String> for UriTemplateLabel
impl From<String> for UriTemplateLabel
Source§impl From<UriTemplateLabel> for Cow<'static, str>
impl From<UriTemplateLabel> for Cow<'static, str>
Source§fn from(label: UriTemplateLabel) -> Self
fn from(label: UriTemplateLabel) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for UriTemplateLabel
impl RefUnwindSafe for UriTemplateLabel
impl Send for UriTemplateLabel
impl Sync for UriTemplateLabel
impl Unpin for UriTemplateLabel
impl UnsafeUnpin for UriTemplateLabel
impl UnwindSafe for UriTemplateLabel
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