ubiq_rust/lib.rs
1//! # ubiq_rust
2//!
3//! Rust client library for the [Ubiq Security](https://ubiqsecurity.com) platform.
4//! Provides both **unstructured** (AES-based) and **structured** (format-preserving)
5//! encryption.
6//!
7//! ## Quick start
8//!
9//! Use the [`builder::Builder`] to construct encryption/decryption objects.
10//! Credentials are loaded from `~/.ubiq/credentials` by default, or can be
11//! configured via environment variables or explicit paths.
12//!
13//! ### Structured (format-preserving) encryption
14//!
15//! ```no_run
16//! # async fn example() -> ubiq_rust::Result<()> {
17//! use ubiq_rust::builder::{Builder, Structured};
18//!
19//! let mut enc = Builder::<Structured>::new().build()?;
20//!
21//! let ciphertext = enc.encrypt("SSN", "123-45-6789", None).await?;
22//! let plaintext = enc.decrypt("SSN", &ciphertext, None).await?;
23//!
24//! assert_eq!(plaintext, "123-45-6789");
25//! # Ok(())
26//! # }
27//! ```
28//!
29//! ### Unstructured encryption
30//!
31//! ```no_run
32//! # async fn example() -> ubiq_rust::Result<()> {
33//! use ubiq_rust::builder::{Builder, Unstructured};
34//!
35//! let mut enc = Builder::<Unstructured>::new()
36//! .build_encryption()
37//! .await?;
38//! let ciphertext = enc.encrypt(b"hello, world!")?;
39//!
40//! let mut dec = Builder::<Unstructured>::new()
41//! .build_decryption()?;
42//! let plaintext = dec.decrypt(&ciphertext).await?;
43//!
44//! assert_eq!(plaintext, b"hello, world!");
45//! # Ok(())
46//! # }
47//! ```
48//!
49//! See the individual module docs and the
50//! [README](https://gitlab.com/ubiqsecurity/ubiq-rust) for more details.
51
52pub(crate) mod auth;
53pub mod builder;
54pub(crate) mod cache;
55pub(crate) mod client;
56pub use client::UbiqClient;
57pub(crate) mod common;
58pub mod config;
59pub mod credentials;
60pub(crate) mod dataset;
61pub mod error;
62pub(crate) mod events;
63pub(crate) mod pipeline;
64pub mod structured;
65pub mod unstructured;
66pub(crate) mod version;
67
68/// Convenience alias for results returned by this crate.
69pub type Result<T> = std::result::Result<T, error::Error>;