Crates.io | woothee |
lib.rs | woothee |
version | 0.13.0 |
source | src |
created_at | 2016-05-06 15:38:10.845013 |
updated_at | 2021-10-31 13:46:18.315378 |
description | user-agent strings parser |
homepage | |
repository | https://github.com/woothee/woothee-rust |
max_upload_size | |
id | 4987 |
size | 9,371,396 |
The Rust implementation of Project Woothee, which is multi-language user-agent strings parsers.
parsing user-agent.
extern crate woothee;
use woothee::parser::Parser;
fn main() {
let parser = Parser::new();
let result = parser.parse("Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)");
println!("{:?}", result);
}
run
Some(WootheeResult { name: "Internet Explorer", category: "pc", os: "Windows 7", os_version: "NT 6.1", browser_type: "UNKNOWN", version: "8.0", vendor: "Microsoft" })
$ cargo +nightly bench
running 8 tests
test bench_stabilizer ... bench: 22 ns/iter (+/- 1)
test create_parser_uap ... bench: 190,983,237 ns/iter (+/- 18,726,783)
test create_parser_uaparser ... bench: 331,963,075 ns/iter (+/- 20,320,543)
test create_parser_woothee ... bench: 0 ns/iter (+/- 0)
test parse_fast_uaparser ... bench: 423,632 ns/iter (+/- 42,520)
test parse_uap ... bench: 606,682 ns/iter (+/- 65,967)
test parse_uaparser ... bench: 826,622 ns/iter (+/- 105,940)
test parse_woothee ... bench: 6,814 ns/iter (+/- 1,924)
generate code from woothee/woothee dataset & testsets.
$ cargo build --features=generate
$ cargo +nightly fmt
$ cargo test # and code review!!!
with clippy lints (optional)
$ rustup component add clippy-preview && cargo clippy