14 releases (5 major breaking)

5.0.0 May 27, 2023
4.0.0 Sep 16, 2022
3.1.1 Sep 9, 2022
2.0.0 May 3, 2022
0.4.0-alpha Apr 18, 2022

#2178 in Parser implementations

45 downloads per month

Apache-2.0

12KB
201 lines

Crates.io Build & Test

trid - Turkish Citizenship ID Number crate

This is my first ever written Rust code derived from my own TurkishId package for .NET. I'm trying to use existing code as an excuse to learn about Rust. Despite constant tackling with error messages, Rust has been extremely impressive so far. (How cool are doc-tests!?)

Usage

The crate provides TurkishId type that represents a valid Turkish ID number. It can be instantiated from a string using the parse() method of str type. TurkishId type guarantess that it never contains an invalid Turkish ID number, so there's no need to validate a TurkishId once parsed. It can always be passed around.

The crate also provides is_valid(value: &str) function for validating ID numbers.

The type occupies 11 bytes in memory and kept as ASCII representation of the number.

Examples

Validate a Turkish citizenship ID number:

if trid::is_valid("12345678901") {
    // yayyy!
}

Try parsing a string into TurkishId:

use trid::TurkishId;

let id : TurkishId = "12345678901".parse()?;

License

Apache License Version 2.0, see LICENSE file for details.

No runtime deps