pub trait Bindable {
// Required method
fn bind_secrets(
&mut self,
registry: &SourceRegistry,
) -> Result<(), Vec<BindError>>;
}Expand description
Implemented by structs that contain one or more Secret fields.
Call bind_all to bind every secret in the struct in one step, collecting
all errors rather than stopping at the first failure.
Implement this trait manually until a derive macro is available:
use secrets_rs::{Bindable, BindError, Secret, SourceRegistry};
struct Config {
api_key: Secret<String>,
}
impl Bindable for Config {
fn bind_secrets(&mut self, registry: &SourceRegistry) -> Result<(), Vec<BindError>> {
let mut errors = Vec::new();
if let Err(e) = self.api_key.bind(registry) {
errors.push(e);
}
if errors.is_empty() { Ok(()) } else { Err(errors) }
}
}Required Methods§
Sourcefn bind_secrets(
&mut self,
registry: &SourceRegistry,
) -> Result<(), Vec<BindError>>
fn bind_secrets( &mut self, registry: &SourceRegistry, ) -> Result<(), Vec<BindError>>
Bind all Secret fields using sources from registry.
Collects every error rather than stopping at the first failure so that callers can report all missing secrets at once.