Skip to main content

SecretField

Trait SecretField 

Source
pub trait SecretField {
    // Required methods
    fn mask(&mut self);
    fn restore_from(&mut self, current: &Self);
    fn encrypt_in_place(
        &mut self,
        store: &SecretStore,
        field: &str,
    ) -> Result<()>;
    fn decrypt_in_place(
        &mut self,
        store: &SecretStore,
        field: &str,
    ) -> Result<()>;
    fn is_set(&self) -> bool;
}
Expand description

Per-field secret operations the Configurable derive emits for every #[secret] field. Generalizes mask / restore / encrypt / decrypt / is_set across the supported shapes — String, Option<String>, Vec<String>, HashMap<String, String>, and Option<HashMap<String, String>> — so adding a new shape is a single trait impl rather than a fourth branch in the macro.

encrypt_in_place and decrypt_in_place are idempotent: encrypting an already-enc2:-prefixed value or decrypting a plaintext value is a no-op, detected via crate::security::SecretStore::is_encrypted. The field argument is the dotted config-path (e.g. mcp.servers); the impls suffix per-element coordinates ([<idx>] for Vec, .<key> for HashMap) so error messages point at the exact failed entry.

Required Methods§

Source

fn mask(&mut self)

Replace each non-empty inner string with MASKED_SECRET.

Source

fn restore_from(&mut self, current: &Self)

Restore inner strings that currently equal MASKED_SECRET from the matching position in current. The dashboard write path relies on this so re-posting an already-displayed masked value doesn’t overwrite the real secret in config.

Source

fn encrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Encrypt every non-empty, not-already-encrypted inner string.

Source

fn decrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Source

fn is_set(&self) -> bool

Whether the field carries at least one non-empty inner string. Reported back through SecretFieldInfo::is_set.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SecretField for Option<String>

Source§

fn mask(&mut self)

Source§

fn restore_from(&mut self, current: &Self)

Source§

fn encrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Source§

fn decrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Source§

fn is_set(&self) -> bool

Source§

impl SecretField for Option<HashMap<String, String>>

Source§

fn mask(&mut self)

Source§

fn restore_from(&mut self, current: &Self)

Source§

fn encrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Source§

fn decrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Source§

fn is_set(&self) -> bool

Source§

impl SecretField for String

Source§

fn mask(&mut self)

Source§

fn restore_from(&mut self, current: &Self)

Source§

fn encrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Source§

fn decrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Source§

fn is_set(&self) -> bool

Source§

impl SecretField for Vec<String>

Source§

fn mask(&mut self)

Source§

fn restore_from(&mut self, current: &Self)

Source§

fn encrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Source§

fn decrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Source§

fn is_set(&self) -> bool

Source§

impl SecretField for HashMap<String, String>

Source§

fn mask(&mut self)

Source§

fn restore_from(&mut self, current: &Self)

Source§

fn encrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Source§

fn decrypt_in_place(&mut self, store: &SecretStore, field: &str) -> Result<()>

Source§

fn is_set(&self) -> bool

Implementors§