pub struct ConfigShape {
pub lib: Symbol,
pub shape: Arc<dyn Shape>,
pub defaults: ConfigTable,
pub secret_keys: Vec<String>,
}Expand description
Shape-backed contract for one library’s configuration table.
Fields§
§lib: SymbolLibrary id whose configuration this shape validates.
shape: Arc<dyn Shape>Shape applied to the effective table after built-in defaults are bound.
defaults: ConfigTableBuilt-in defaults for absent fields.
secret_keys: Vec<String>Top-level keys whose values are secret-bearing.
Implementations§
Source§impl ConfigShape
impl ConfigShape
Sourcepub fn new(lib: Symbol, shape: Arc<dyn Shape>, defaults: ConfigTable) -> Self
pub fn new(lib: Symbol, shape: Arc<dyn Shape>, defaults: ConfigTable) -> Self
Creates a config shape with no secret keys.
Sourcepub fn with_secret_keys(
self,
keys: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_secret_keys( self, keys: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Adds secret keys, deduplicating them at the shape boundary.
Sourcepub fn validate(
&self,
cx: &mut Cx,
table: &ConfigTable,
) -> ConfigShapeResult<ConfigTable>
pub fn validate( &self, cx: &mut Cx, table: &ConfigTable, ) -> ConfigShapeResult<ConfigTable>
Validates table against this shape and returns the default-bound table.
Built-in defaults are the lowest-precedence layer. The supplied table overlays them, then the configured shape checks the effective table. A closed table shape therefore reports unknown fields while defaults may satisfy required fields.
Sourcepub fn defaults_layer(&self) -> ConfigLayer
pub fn defaults_layer(&self) -> ConfigLayer
Returns this shape’s built-in defaults as a merge layer.
Sourcepub fn marks_secret(&self, key: &str) -> bool
pub fn marks_secret(&self, key: &str) -> bool
Returns true when key is marked as secret-bearing by this shape.
Sourcepub fn secret_fields(&self) -> Vec<ConfigSecretField>
pub fn secret_fields(&self) -> Vec<ConfigSecretField>
Returns secret field records for report and redaction code.
Trait Implementations§
Source§impl Clone for ConfigShape
impl Clone for ConfigShape
Source§fn clone(&self) -> ConfigShape
fn clone(&self) -> ConfigShape
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more