Rust

detection

Module

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

PHP: Utopia\UserAgent\Detection\*.

Contents

use utopia_user_agent::detection::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).

PHP: BotDetector::detect().

use utopia_user_agent::detection::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.

PHP: ClientDetector::detect().

use utopia_user_agent::detection::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.

PHP: DeviceDetector::detect().

use utopia_user_agent::detection::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.

PHP: OperatingSystemDetector::detect().