pub struct HttpHeaderTrait<'a> { /* private fields */ }Expand description
The @httpHeader trait — binds a member to an HTTP header.
Implementations§
Source§impl<'a> HttpHeaderTrait<'a>
impl<'a> HttpHeaderTrait<'a>
Sourcepub const fn new(value: &'static str) -> Self
pub const fn new(value: &'static str) -> Self
Creates a new instance from a 'static header name.
Unlike the other wire-format traits this requires 'static, so that
value_static can hand the HTTP binder a name it
inserts into Headers without allocating. Schemas materialized at
runtime must intern or leak their header names; every other
wire-format trait accepts an arbitrary lifetime.
Sourcepub fn value(&self) -> &'a str
pub fn value(&self) -> &'a str
Returns the header name.
Bound to the schema’s data lifetime 'a, matching the other trait
wrappers. Use value_static when the name has to
outlive the schema, as it does for header insertion.
Sourcepub fn value_static(&self) -> Option<&'static str>
pub fn value_static(&self) -> Option<&'static str>
Returns the header name if it is 'static.
This is what Headers::insert needs for an allocation-free insert.
Always Some today, because new is the only constructor
and it requires 'static. Callers must nonetheless handle None and
fall back to an owned string rather than unwrapping: relaxing this
trait to accept runtime-borrowed names is intended to be additive, and
at that point this returns None for arena-borrowed names.
Trait Implementations§
Source§impl<'a> Clone for HttpHeaderTrait<'a>
impl<'a> Clone for HttpHeaderTrait<'a>
Source§impl<'a> Debug for HttpHeaderTrait<'a>
impl<'a> Debug for HttpHeaderTrait<'a>
Auto Trait Implementations§
impl<'a> Freeze for HttpHeaderTrait<'a>
impl<'a> RefUnwindSafe for HttpHeaderTrait<'a>
impl<'a> Send for HttpHeaderTrait<'a>
impl<'a> Sync for HttpHeaderTrait<'a>
impl<'a> Unpin for HttpHeaderTrait<'a>
impl<'a> UnsafeUnpin for HttpHeaderTrait<'a>
impl<'a> UnwindSafe for HttpHeaderTrait<'a>
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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