Skip to main content

ConfigShape

Struct ConfigShape 

Source
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: Symbol

Library id whose configuration this shape validates.

§shape: Arc<dyn Shape>

Shape applied to the effective table after built-in defaults are bound.

§defaults: ConfigTable

Built-in defaults for absent fields.

§secret_keys: Vec<String>

Top-level keys whose values are secret-bearing.

Implementations§

Source§

impl ConfigShape

Source

pub fn new(lib: Symbol, shape: Arc<dyn Shape>, defaults: ConfigTable) -> Self

Creates a config shape with no secret keys.

Source

pub fn with_secret_keys( self, keys: impl IntoIterator<Item = impl Into<String>>, ) -> Self

Adds secret keys, deduplicating them at the shape boundary.

Source

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.

Source

pub fn defaults_layer(&self) -> ConfigLayer

Returns this shape’s built-in defaults as a merge layer.

Source

pub fn marks_secret(&self, key: &str) -> bool

Returns true when key is marked as secret-bearing by this shape.

Source

pub fn secret_fields(&self) -> Vec<ConfigSecretField>

Returns secret field records for report and redaction code.

Trait Implementations§

Source§

impl Clone for ConfigShape

Source§

fn clone(&self) -> ConfigShape

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.