lib2fas 0.0.4

Unofficial implementation of 2fas for Rust (as a library).
Documentation
# lib2fas.rs

**`lib2fas`** is an unofficial implementation of the [2fas](https://2fas.com/) platform for Rust, providing tools for
managing and interacting with two-factor authentication (2FA) services as a library.

## Installation

Add `lib2fas` to your `Cargo.toml`:

```shell
cargo add lib2fas
```

Or add it manually with a specific version:

```toml
# Cargo.toml
[dependencies]
lib2fas = "x.y.z"
```

## Usage

### Loading and Querying 2FA Services

```rust
use lib2fas::load_services;

#[tokio::main]
async fn main() {
    let maybe_storage = load_services("path/to/services.2fas", Some("your-passphrase")).await;

    match maybe_storage {
        Ok(storage) => {
            println!("Loaded {} services", storage.len());

            if let Some(service) = storage.find_first("example-service") {
                println!("Found service: {}", service.name);

                if let Some(otp) = service.totp() {
                    println!("Current OTP: {}", otp);
                }

                if let Some(next_otp) = service.totp_next() {
                    println!("Next OTP: {}", next_otp);
                }

                if let Some(current_otp_u32) = service.totp_u32() {
                    println!("Current OTP (as number): {}", current_otp_u32);
                }
            } else {
                println!("Service not found.");
            }
        }
        Err(err) => {
            eprintln!("Failed to load services: {}", err);
        }
    }
}
```

### Testing

Run tests with output to stdout:

```bash
cargo test -- --nocapture
```

Run tests with coverage output:

```bash
cargo tarpaulin --out Html
```

## Documentation

For more detailed information, visit [docs.rs/lib2fas](https://docs.rs/lib2fas).

## Source Code

The source code is available on [GitHub](https://github.com/robinvandernoord/lib2fas-rust).