Rust

Crate root

Module
What utopia_user_agent defines at its root.

Modules

Contents

use utopia_user_agent::Bot;
Rust
pub struct Bot<'a> {
    pub name: Text<'a>,
    pub category: Text<'a>,
}

A bot a user-agent string names: a crawler, preview fetcher, monitor or automation tool.

PHP: Utopia\UserAgent\Bot.

use utopia_user_agent::Client;
Rust
pub struct Client<'a> {
    pub kind: Option<Text<'a>>,
    pub code: Option<Text<'a>>,
    pub name: Option<Text<'a>>,
    pub version: Option<Text<'a>>,
    pub engine: Option<Text<'a>>,
    pub engine_version: Option<Text<'a>>,
}

The client a user-agent string names: a browser, an HTTP library or a native app.

PHP: Utopia\UserAgent\Client.

use utopia_user_agent::Device;
Rust
pub struct Device<'a> {
    pub kind: Option<Text<'a>>,
    pub brand: Option<Text<'a>>,
    pub model: Option<Text<'a>>,
}

The device a user-agent string names.

PHP: Utopia\UserAgent\Device.

use utopia_user_agent::OperatingSystem;
Rust
pub struct OperatingSystem<'a> {
    pub code: Option<Text<'a>>,
    pub name: Option<Text<'a>>,
    pub version: Option<Text<'a>>,
}

The operating system a user-agent string names; every field is None when it names none.

PHP: Utopia\UserAgent\OperatingSystem.

use utopia_user_agent::UserAgent;
Rust
pub struct UserAgent<'a> {
    // private fields
}

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.

Rust
pub type Text<'a> = Cow<'a, [u8]>;

A text value: borrowed from the user-agent or from a static table, owned when detection rewrites it (17_4 becomes 17.4).