digipin/lib.rs
1// Copyright (c) 2026 Pranam
2// ORCID: https://orcid.org/0009-0007-9316-3616
3//
4// This code is licensed under the Apache License, Version 2.0.
5//
6// You may obtain a copy of the License at
7//
8// https://www.apache.org/licenses/LICENSE-2.0
9//
10// QR Code:
11// 
12// Scan the QR code to access my ORCID profile.
13
14/// DIGIPIN – Digital Postal Index Number
15///
16/// This library provides functionality to encode geographic locations
17/// (latitude and longitude) into a canonical 10-character DIGIPIN string
18/// and decode DIGIPIN strings back into geographic locations.
19///
20/// Public API:
21/// - `encode`: Encode geographic coordinates into DIGIPIN strings.
22/// - `decode`: Decode DIGIPIN strings into geographic coordinates.
23/// - `errors`: Error types for DIGIPIN operations.
24/// # Usage
25/// To use this library, include it as a dependency in your Rust project and call the
26/// `encode` and `decode` functions as needed.
27/// ```rust
28/// use digipin::{encode, decode, Location};
29/// fn main() -> Result<(), Box<dyn std::error::Error>> {
30/// let location = Location {
31/// latitude: 28.622788,
32/// longitude: 77.213033,
33/// };
34/// let digipin = encode(location)?;
35/// let decoded_location = decode(&digipin)?;
36/// println!("DIGIPIN: {}", digipin);
37/// println!("Decoded Location: {:?}", decoded_location);
38/// Ok(())
39/// }
40/// ```
41mod constants;
42mod decode;
43mod encode;
44mod errors;
45mod location;
46mod normalize;
47mod validation;
48
49pub use decode::decode;
50pub use encode::encode;
51pub use errors::DigipinError;
52pub use location::Location;
53
54#[cfg(test)]
55mod tests;