tripfuse π₯
One-time use container for sensitive values - like OTPs, API keys, authenticators, and secrets.
β‘ Features
- β One-time guarantee - Value can be extracted exactly once
- β Zero dependencies - No external crates, minimal footprint
- β No unsafe code - 100% safe Rust
- β
Compile-time enforcement - Prevents accidental reference passing with
'staticbound - β Explicit burn - Manually destroy the fuse without extracting
- β Security-focused - Values are moved out, not copied or cloned
Exambles folder follow link examples
π Quick Start
use OnceFuse;
// Create a fuse with your secret
let mut fuse = new;
// Use it once - value moves out
let secret = fuse.try_use.unwrap;
println!;
// Second use fails
assert!;
π¦Installation
Add to your Cargo.toml:
[]
= "0.1.0"
πSecurity Guarantees
β Do this:
// Owned types are perfect
let fuse = new;
let fuse = new;
let fuse = new;
// String literals work too
let fuse = new;
β Don't do this:
let secret = Stringfrom;
let fuse = new; // β Won't compile with 'static bound
// secret remains accessible - security risk!
π API Overview
-
OnceFuse::new(value)Creates a new fuse, taking ownership of the value. -
try_use(&mut self) -> Result<T, TripError>Extracts the inner value - succeeds only once. -
burn_it(&mut self) -> boolExplicitly destroys the fuse. Returns true if this call caused the burn. -
is_armed(&self) -> boolChecks if the fuse is still usable.
π― Use Cases
-
OTP (One-Time Passwords) - Ensure each code is used once
-
API Keys - Prevent key reuse after initial authentication
-
Cryptographic Keys - Move sensitive keys out of memory after use
-
Authenticators - One-time tokens for 2FA
-
Consumable Resources - Any value that should be used exactly once
π§ Error Handling
use ;
let mut fuse = new;
match fuse.try_use
π§ͺ Example: OTP Verification
use OnceFuse;
;
let otp = send_otp;
assert!; // First use - OK
// Second use would fail automatically
π§ͺ Example: OTP Simple Send, Recieve
use ;
π§ Design Notes
-
Clone is intentionally not implemented - prevents - duplicate access
-
Copy is impossible due to internal state tracking
-
Drop is automatic - no manual cleanup needed
-
Uses std::mem::replace for safe state transitions
π License
MIT Β© [oOp995]
π€ Contributing
Contributions welcome! Please ensure:
-
No external dependencies
-
Maintain 100% test coverage
-
Document all public APIs
-
No unsafe code (unless no other solution exists)
Made with π for security-conscious Rust developers