pub struct RawUserAgentInfo<S: Default + AsRef<str>> {
pub user_agent: Option<S>,
pub client_hints: ClientHints<S>,
}
Expand description
A container housing both the user-agent string and the client hint headers.
Useful for the scenarios where you will use either information from client hints if it exists, and if not fall back to user agent string.
Fields§
§user_agent: Option<S>
The “old style” of a single UA string.
client_hints: ClientHints<S>
User-Agent client hints.
Implementations§
source§impl<S: AsRef<str> + Default> RawUserAgentInfo<S>
impl<S: AsRef<str> + Default> RawUserAgentInfo<S>
sourcepub fn set_ua_field_from_header(&mut self, key: &str, value: Option<S>)
pub fn set_ua_field_from_header(&mut self, key: &str, value: Option<S>)
Checks if key matches a user agent header, in which case it sets the value accordingly. TODO(tor): make it generic over different header types.
sourcepub fn populate_event_headers(&self, headers: &mut Headers)
pub fn populate_event_headers(&self, headers: &mut Headers)
Convert user-agent info to HTTP headers as stored in the Request
interface.
This function does not overwrite any pre-existing headers.
source§impl RawUserAgentInfo<String>
impl RawUserAgentInfo<String>
sourcepub const USER_AGENT: &'static str = "User-Agent"
pub const USER_AGENT: &'static str = "User-Agent"
The name of the user agent HTTP header.
sourcepub fn as_deref(&self) -> RawUserAgentInfo<&str>
pub fn as_deref(&self) -> RawUserAgentInfo<&str>
Converts to a borrowed RawUserAgentInfo
.
source§impl<'a> RawUserAgentInfo<&'a str>
impl<'a> RawUserAgentInfo<&'a str>
sourcepub fn from_headers(headers: &'a Headers) -> Self
pub fn from_headers(headers: &'a Headers) -> Self
Computes a borrowed RawUserAgentInfo
from the given HTTP headers.
This extracts both the user agent as well as client hints if available. Use
is_empty
to check whether information could be extracted.
Trait Implementations§
source§impl<S: Clone + Default + AsRef<str>> Clone for RawUserAgentInfo<S>
impl<S: Clone + Default + AsRef<str>> Clone for RawUserAgentInfo<S>
source§fn clone(&self) -> RawUserAgentInfo<S>
fn clone(&self) -> RawUserAgentInfo<S>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<S: Default + Default + AsRef<str>> Default for RawUserAgentInfo<S>
impl<S: Default + Default + AsRef<str>> Default for RawUserAgentInfo<S>
source§fn default() -> RawUserAgentInfo<S>
fn default() -> RawUserAgentInfo<S>
source§impl<'de, S> Deserialize<'de> for RawUserAgentInfo<S>
impl<'de, S> Deserialize<'de> for RawUserAgentInfo<S>
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>,
source§impl<S> Serialize for RawUserAgentInfo<S>
impl<S> Serialize for RawUserAgentInfo<S>
impl<S: Default + AsRef<str>> StructuralPartialEq for RawUserAgentInfo<S>
Auto Trait Implementations§
impl<S> Freeze for RawUserAgentInfo<S>where
S: Freeze,
impl<S> RefUnwindSafe for RawUserAgentInfo<S>where
S: RefUnwindSafe,
impl<S> Send for RawUserAgentInfo<S>where
S: Send,
impl<S> Sync for RawUserAgentInfo<S>where
S: Sync,
impl<S> Unpin for RawUserAgentInfo<S>where
S: Unpin,
impl<S> UnwindSafe for RawUserAgentInfo<S>where
S: UnwindSafe,
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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