#user #agent

uap-rust

User agent parser library for Rust based on the ua-parser project

4 releases

Uses old Rust 2015

0.0.4 Apr 5, 2016
0.0.3 Feb 21, 2016
0.0.2 Feb 21, 2016
0.0.1 Feb 16, 2016

#400 in HTTP client

Download history 21/week @ 2023-10-28 13/week @ 2023-11-04 10/week @ 2023-11-11 15/week @ 2023-11-18 17/week @ 2023-11-25 12/week @ 2023-12-02 10/week @ 2023-12-09 16/week @ 2023-12-16 16/week @ 2023-12-23 11/week @ 2023-12-30 11/week @ 2024-01-06 12/week @ 2024-01-13 14/week @ 2024-01-20 13/week @ 2024-01-27 7/week @ 2024-02-03 20/week @ 2024-02-10

56 downloads per month
Used in woothee

MIT license

785KB
569 lines

#ua-parser for rust User agent parser library for Rust based on the ua-parser project.

Add to your Cargo.toml:

[dependencies]
uap-rust = "0.0.*"

##Usage example

use uap_rust::parser::Parser;
let agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3".to_string();
let p = Parser::new().unwrap();
let c = p.parse(agent);

println!("{:?}",c);
 //Output: Client { user_agent: UserAgent { family: "Mobile Safari", major: Some("5"), minor: Some("1"), patch: None }, os: OS { family: "iOS", major: Some("5"), minor: Some("1"), patch: Some("1"), patch_minor: None }, device: Device { family: "iPhone", brand: Some("Apple"), model: Some("iPhone") } }

##Documentation

Documentation is available here

##Building from source. Recursive clone the uap-core project for the parser regexes:

git submodule update --init --recursive

Then simply build or run tests via cargo:

cargo build
cargo test

Dependencies

~3.5MB
~79K SLoC