Configuration

Struct Configuration 

Source
pub struct Configuration { /* private fields */ }
Expand description

One possible “shape” the flattened type could take.

Represents a specific choice of variants for all enums in the flatten tree.

Implementations§

Source§

impl Configuration

Source

pub fn matches(&self, input_fields: &BTreeSet<&str>) -> MatchResult

Check if this configuration matches the input fields.

Source

pub fn describe(&self) -> String

Get a human-readable description of this configuration.

Returns something like MessagePayload::Text or Auth::Token + Transport::Tcp for configurations with multiple variant selections.

Source

pub fn deserialization_order(&self) -> Vec<&FieldInfo>

Get the fields in deserialization order (deepest first).

Source

pub fn field(&self, name: &str) -> Option<&FieldInfo>

Get a field by name.

Source

pub fn fields(&self) -> &BTreeMap<&'static str, FieldInfo>

Get all fields.

Source

pub fn missing_optional_fields<'a>( &'a self, seen_keys: &'a BTreeSet<&str>, ) -> impl Iterator<Item = &'a FieldInfo>

Get optional fields that were NOT provided in the input.

This is useful for deserializers that need to initialize missing optional fields to None or their default value.

§Example
#[derive(Facet)]
struct Config {
    required_field: String,
    optional_field: Option<u32>,
}

let schema = Schema::build(Config::SHAPE).unwrap();
let config = &schema.configurations()[0];

// If we only saw "required_field"
let mut seen = BTreeSet::new();
seen.insert("required_field");

let missing: Vec<_> = config.missing_optional_fields(&seen).collect();
assert_eq!(missing.len(), 1);
assert_eq!(missing[0].serialized_name, "optional_field");
Source

pub fn variant_selections(&self) -> &[VariantSelection]

Get variant selections.

Source

pub fn known_paths(&self) -> &BTreeSet<KeyPath>

Get all known key paths (for depth-aware probing).

Source

pub fn has_key_path(&self, path: &[&str]) -> bool

Check if this configuration has a specific key path. Compares runtime strings against static schema paths.

Trait Implementations§

Source§

impl Clone for Configuration

Source§

fn clone(&self) -> Configuration

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Configuration

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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.