-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configurability for unicode and skipping parsers (#14)
* Add configurability for unicode and skipping parsers - Unicode support greatly increases memory and latency and is not generally needed. - Compiling regex for unused parsers is just a waste of memory. Both unicode support and device/os/user_agent parsers can now be configured via `UserAgentParserBuilder`. * Hide UserAgentParserBuilder behind builder method * Update tests/bench/examples with new builder syntax --------- Co-authored-by: David Armstrong Lewis <6754950+davidarmstronglewis@users.noreply.github.com>
- Loading branch information
1 parent
ad3af40
commit 71a5f66
Showing
15 changed files
with
453 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use uaparser::{Parser, UserAgentParser}; | ||
|
||
fn main() { | ||
let parser = UserAgentParser::builder() | ||
.build_from_yaml("./src/core/regexes.yaml") | ||
.expect("Parser creation failed"); | ||
|
||
println!("{:?}", parser.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use uaparser::{Parser, UserAgentParser}; | ||
|
||
fn main() { | ||
let parser = UserAgentParser::builder() | ||
.with_unicode_support(false) | ||
.build_from_yaml("./src/core/regexes.yaml") | ||
.expect("Parser creation failed"); | ||
|
||
println!("{:?}", parser.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use uaparser::{Parser, UserAgentParser}; | ||
|
||
fn main() { | ||
let parser = UserAgentParser::builder() | ||
.with_unicode_support(false) | ||
.with_device(false) | ||
.with_os(true) | ||
.with_user_agent(false) | ||
.build_from_yaml("./src/core/regexes.yaml") | ||
.expect("Parser creation failed"); | ||
|
||
println!("{:?}", parser.parse("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36")) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.