pub struct UserAgent<'a> { /* private fields */ }Expand description
A lazily evaluated analysis of one user-agent string.
Each category is detected at most once, on first access. Bot detection is independent from client and device detection: a bot never suppresses the other results.
Implementations§
Source§impl<'a> UserAgent<'a>
impl<'a> UserAgent<'a>
Sourcepub fn parse(value: &'a (impl AsRef<[u8]> + ?Sized)) -> Self
pub fn parse(value: &'a (impl AsRef<[u8]> + ?Sized)) -> Self
Wraps a user-agent string without detecting anything yet.
Accepts any bytes, as a header can carry them.
PHP: UserAgent::parse().
Sourcepub fn operating_system(&self) -> &OperatingSystem<'a>
pub fn operating_system(&self) -> &OperatingSystem<'a>
The operating system, detected on first call.
PHP: operatingSystem().
Sourcepub fn client(&self) -> &Client<'a>
pub fn client(&self) -> &Client<'a>
The client (browser, HTTP library or native app), detected on first call.
PHP: client().
Sourcepub fn bot(&self) -> Option<&Bot<'a>>
pub fn bot(&self) -> Option<&Bot<'a>>
The bot behind the string, or None for a human client. Detected on
first call.
PHP: bot().
Sourcepub fn is_bot(&self) -> bool
pub fn is_bot(&self) -> bool
Whether the string belongs to a bot (UserAgent::bot is Some).
PHP: isBot().
Trait Implementations§
Auto Trait Implementations§
impl<'a> !Freeze for UserAgent<'a>
impl<'a> !RefUnwindSafe for UserAgent<'a>
impl<'a> !Sync for UserAgent<'a>
impl<'a> Forget for UserAgent<'a>
impl<'a> Move for UserAgent<'a>
impl<'a> Send for UserAgent<'a>
impl<'a> Unpin for UserAgent<'a>
impl<'a> UnsafeUnpin for UserAgent<'a>
impl<'a> UnwindSafe for UserAgent<'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
Mutably borrows from an owned value. Read more