1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! # memguard-rs
//!
//! Secure memory handling primitives for Rust.
//!
//! ## Features
//!
//! - **Zeroization on drop** — volatile-write memory clearing the compiler cannot optimize away
//! - **Memory locking** — `mlock`/`VirtualLock` to prevent secrets from being written to swap
//! - **Constant-time comparison** — timing side-channel resistant equality checks for secrets
//! - **Compile-time guarded regions** — const-generic memory regions with type-level size enforcement
//! - **`no_std` compatible** — core primitives work without an allocator
//! - **Zero dependencies** — no transitive dependency surface to audit
//!
//! ## Quick start
//!
//! ```rust
//! use memguard_rs::Secret;
//!
//! let mut key = Secret::new([0u8; 32]);
//!
//! // Access the secret only within a closure — it's not exposed outside
//! key.expose(|k| {
//! assert_eq!(k.len(), 32);
//! });
//!
//! // Modify in place
//! key.expose_mut(|k| {
//! k[0] = 0xFF;
//! });
//!
//! // When `key` goes out of scope, its memory is zeroized via volatile writes
//! ```
extern crate alloc;
pub use ;
pub use ;
pub use GuardedRegion;
pub use Secret;
pub use Zeroize;