The fastest way to identify anything!
We switched from Lazy<Vec<Regex>>
to Vec<Lazy<Regex>>
!
This release provides major performance boost by compiling only those regular expressions that are required.
It was storing regexes as Lazy<Vec<Regex>>
, so even though we were compiling it only once, we were compiling them all! But some regex like URL are huge, and regex compilation is expensive. Fixing it is easy, just don't compile all regex at once, instead compile them as required, i.e. Vec<Lazy<Regex>>
!
Being able to match on bytes was a requirement for API users, that is why lemmeknow is now using regex crate instead of fancy_regex to get bytes support.
But there is always a tradeoff, regex crate isn't fancy. It doesn't support look-around.
Below is the list of regex which won't compile because of using look-around.
- Internet Protocol (IP) Address Version 6
- Bitcoin (₿) Wallet Address
- American Social Security Number
- Date of Birth
- JSON Web Token (JWT)
- Amazon Web Services Access Key
- Amazon Web Services Secret Access Key
- YouTube Video ID
There are other changes for hopefully performance improvement like parsing regex.json
file at compile time.
Full Changelog: https://github.com/swanandx/lemmeknow/compare/v0.6.0...v0.7.0
first_match()
to get the first identification - docs
let identifier = lemmeknow::Identifier::default();
let some_result = identifier.first_match("8888888888");
let not_gonna_find = identifier.first_match("a friend for swanandx");
assert_eq!(some_result.unwrap().data.name, "Phone Number");
assert!(not_gonna_find.is_none());
what else? well actually, we got old stuff back!
Identify
is now Identifier
( makes more sense ).min_rarity
and max_rarity
are now f32
instead of Option<f32>
( let me know if Option was better )Bug Fix for API users: We used to call build_regexes
inside identify
, which kept building regexes everytime we call identify
making it slow. Instead of this, now regexes are built and stored in lazy static. Which means they are compiled only when first accessed.
lemmeknow now supports webassembly! It can be compiled to wasm <3 You can directly use it as dependency in your project for wasm and it works out of the box! For example, here is fronted made using Yew - link .
What's new?
lemmeknow
as API!Cargo.toml