detection
ModuleThe 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;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;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;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;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().