Rust

detection

Module

The detectors: pure functions from a user-agent string to what it reveals. UserAgent runs them lazily and keeps their results.

Contents

4 submodules.

detection::bot

Own page

Bot detection: known bots by name, then a generic rule for crawlers.

use utopia_user_agent::detection::bot::bot;
Rust
pub fn bot(user_agent: &[u8]) -> Option<Bot<'_>>

The bot behind a user-agent string: a known bot, or one with a token ending in bot, crawler, spider, scraper or slurp (category Bot::CRAWLER).

detection::client

Own page

Client detection: browsers and their engines, HTTP libraries and native apps.

use utopia_user_agent::detection::client::client;
Rust
pub fn client(user_agent: &[u8]) -> Client<'_>

The client behind a user-agent string: the first rule that recognises it.

Specific browsers resolve before the engines they embed (Edge, Opera and the Chromium derivatives before Chrome), then libraries, then native apps.

detection::device

Own page

Device detection: the kind, brand and model of the device.

use utopia_user_agent::detection::device::device;
Rust
pub fn device(user_agent: &[u8]) -> Device<'_>

The device behind a user-agent string, tried in order: consoles, TVs, Apple devices, Windows phones, Kindles, Android devices, BlackBerrys, then desktops.

detection::os

Own page

Operating system detection: the system's code, name and version.

use utopia_user_agent::detection::os::operating_system;
Rust
pub fn operating_system(user_agent: &[u8]) -> OperatingSystem<'_>

The operating system behind a user-agent string; every field is None for an empty or unrecognised string.

Windows reports its release (7 for Windows NT 6.1) and macOS its version up to the second dot; underscores in versions become dots.