Skip to main content

SchemaNode

Struct SchemaNode 

Source
pub struct SchemaNode {
Show 13 fields pub path: String, pub name: String, pub kind: SchemaKind, pub rust_type: String, pub required: bool, pub nullable: bool, pub default: Option<Value>, pub aliases: Vec<String>, pub env: Option<EnvBinding>, pub merge_hint: Option<MergeHint>, pub docs: Option<String>, pub validations: Vec<ValidationRule>, pub children: BTreeMap<String, Self>,
}
Expand description

Schema node describing a configuration path.

Fields§

§path: String

JSON Pointer path for this node.

§name: String

Logical field name.

§kind: SchemaKind

Schema kind.

§rust_type: String

Rust type name.

§required: bool

Whether this node is required.

§nullable: bool

Whether this node accepts null.

§default: Option<Value>

Default value.

§aliases: Vec<String>

Alias names for the node.

§env: Option<EnvBinding>

Environment binding metadata.

§merge_hint: Option<MergeHint>

Merge hint for the node.

§docs: Option<String>

Documentation string.

§validations: Vec<ValidationRule>

Validation rules.

§children: BTreeMap<String, Self>

Child nodes.

Implementations§

Source§

impl SchemaNode

Source

pub fn new( path: impl Into<String>, name: impl Into<String>, kind: SchemaKind, rust_type: impl Into<String>, ) -> Self

Create a new schema node.

Source

pub const fn required(self, required: bool) -> Self

Mark the node as required.

Source

pub const fn nullable(self, nullable: bool) -> Self

Mark the node as nullable.

Source

pub fn default_value(self, default: Value) -> Self

Set the default value.

Source

pub fn alias(self, alias: impl Into<String>) -> Self

Add an alias.

Source

pub fn env_binding(self, env: EnvBinding) -> Self

Set environment metadata.

Source

pub const fn merge_hint(self, merge_hint: MergeHint) -> Self

Set merge hint.

Source

pub fn docs(self, docs: impl Into<String>) -> Self

Set docs text.

Source

pub fn validation(self, rule: ValidationRule) -> Self

Add a validation rule.

Source

pub fn child(self, key: impl Into<String>, child: Self) -> Self

Add a child node.

Source

pub fn find<'a>(&'a self, path: &str) -> Option<&'a Self>

Find a node by JSON Pointer path.

Trait Implementations§

Source§

impl Clone for SchemaNode

Source§

fn clone(&self) -> SchemaNode

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 SchemaNode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SchemaNode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for SchemaNode

Source§

fn eq(&self, other: &SchemaNode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for SchemaNode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SchemaNode

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,