pub struct Secret { /* private fields */ }Expand description
UTF-8 secret material whose backing bytes are overwritten when dropped.
This type intentionally does not implement Clone, Debug, Display, or
serde traits. Callers must opt in to access through Secret::expose_secret.
The standard-library-only overwrite is a defense-in-depth measure, not a
compiler-guaranteed secure erasure primitive.
ⓘ
use rustferry_remote::Secret;
let secret = Secret::new("private-key-value");
println!("{secret:?}");ⓘ
use rustferry_remote::Secret;
let secret = Secret::new("password-value");
let _copy = secret.clone();ⓘ
use rustferry_remote::Secret;
let secret = Secret::new("password-value");
let _json = serde_json::to_string(&secret).unwrap();Implementations§
Source§impl Secret
impl Secret
Sourcepub fn new(value: impl Into<String>) -> Self
pub fn new(value: impl Into<String>) -> Self
Store one UTF-8 secret, taking ownership when the input is an owned string.
Sourcepub fn expose_secret(&self) -> &str
pub fn expose_secret(&self) -> &str
Expose the secret to the narrow operation that needs it.
§Panics
This cannot panic through the public API because construction accepts only UTF-8 strings.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Secret
impl RefUnwindSafe for Secret
impl Send for Secret
impl Sync for Secret
impl Unpin for Secret
impl UnsafeUnpin for Secret
impl UnwindSafe for Secret
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more