imei

Crates.ioimei
lib.rsimei
version1.1.1
sourcesrc
created_at2022-03-01 16:39:25.009183
updated_at2023-03-21 20:33:48.441658
descriptionAn IMEI number validator
homepage
repositoryhttps://github.com/grantshandy/imei
max_upload_size
id541656
size22,926
Grant Handy (grantshandy)

documentation

https://docs.rs/imei

README

imei

An IMEI number validator implemented in Rust.

imei = "1"

Example

Basic example:

fn main() {
    let num = "490154203237518";
    let valid = imei::valid(num);

    println!("{num}: {valid}");
}

Result:

490154203237518: true

Speed

This validator is designed to be as fast and efficient as possible. It uses small number types, precalculates the character conversions, and only iterates through the imei number once. The speed test in the tests directory gets the average speed of validation over 10,000,000 cycles. Typically, the validation process sub 1000th of a milisecond (practically instant!).

Features

  • The std is enabled by default which implements error::Error for imei::Error.
  • The serde feature adds serialization/deserialization for the Imei struct.
Commit count: 16

cargo fmt