Value

Enum Value 

Source
pub enum Value {
    Null,
    Bool(bool),
    Integer(i64),
    Float(f64),
    String(String),
    Bytes(Vec<u8>),
    Sequence(Vec<Value>),
    Mapping(IndexMap<String, Value>),
}
Expand description

A configuration value that may contain unresolved interpolations

The Bytes variant stores raw binary data and serializes to base64 in YAML/JSON.

Variants§

§

Null

Null value

§

Bool(bool)

Boolean value

§

Integer(i64)

Integer value

§

Float(f64)

Floating point value

§

String(String)

String value (may contain interpolations like ${env:VAR})

§

Bytes(Vec<u8>)

Binary data (serializes to base64)

§

Sequence(Vec<Value>)

Sequence of values

§

Mapping(IndexMap<String, Value>)

Mapping of string keys to values

Implementations§

Source§

impl Value

Source

pub fn is_null(&self) -> bool

Check if this value is null

Source

pub fn is_bool(&self) -> bool

Check if this value is a boolean

Source

pub fn is_integer(&self) -> bool

Check if this value is an integer

Source

pub fn is_float(&self) -> bool

Check if this value is a float

Source

pub fn is_string(&self) -> bool

Check if this value is a string

Source

pub fn is_sequence(&self) -> bool

Check if this value is a sequence

Source

pub fn is_mapping(&self) -> bool

Check if this value is a mapping

Source

pub fn is_bytes(&self) -> bool

Check if this value is bytes

Source

pub fn as_bool(&self) -> Option<bool>

Get as boolean if this is a Bool

Source

pub fn as_i64(&self) -> Option<i64>

Get as i64 if this is an Integer

Source

pub fn as_f64(&self) -> Option<f64>

Get as f64 if this is a Float or Integer

Source

pub fn as_str(&self) -> Option<&str>

Get as str if this is a String

Source

pub fn as_sequence(&self) -> Option<&[Value]>

Get as slice if this is a Sequence

Source

pub fn as_mapping(&self) -> Option<&IndexMap<String, Value>>

Get as mapping if this is a Mapping

Source

pub fn as_bytes(&self) -> Option<&[u8]>

Get as bytes if this is Bytes

Source

pub fn get_path(&self, path: &str) -> Result<&Value>

Get a value by path (e.g., “database.host” or “servers[0].name”)

Source

pub fn get_path_mut(&mut self, path: &str) -> Result<&mut Value>

Get a mutable value by path

Source

pub fn set_path(&mut self, path: &str, value: Value) -> Result<()>

Set a value at a path, creating intermediate mappings as needed

Source

pub fn type_name(&self) -> &'static str

Returns the type name of this value

Source

pub fn merge(&mut self, other: Value)

Merge another value into this one (deep merge per ADR-004)

Merge semantics:

  • Mappings: Deep merge recursively
  • Scalars: other wins (last-writer-wins)
  • Sequences: other replaces entirely
  • Null in other: Removes the key (handled by caller)
  • Type mismatch: other wins
Source

pub fn merged(self, other: Value) -> Value

Create a merged value from two values (non-mutating)

Source

pub fn merge_tracking_sources( &mut self, other: Value, source: &str, path_prefix: &str, sources: &mut HashMap<String, String>, )

Merge another value into this one while tracking source files

Like merge(), but also records which file each leaf value came from. The sources map is updated to reflect the final source of each path.

Source

pub fn collect_leaf_paths( &self, path_prefix: &str, source: &str, sources: &mut HashMap<String, String>, )

Collect all leaf paths from this value and record their source

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

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 Value

Source§

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

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

impl Default for Value

Source§

fn default() -> Value

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Value

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 Display for Value

Source§

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

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

impl From<&str> for Value

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<IndexMap<String, Value>> for Value

Source§

fn from(m: IndexMap<String, Value>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Value> for ResolvedValue

Source§

fn from(value: Value) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value>> From<Vec<T>> for Value

Source§

fn from(v: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Value

Source§

fn from(bytes: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(f: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(i: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(i: i64) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> 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 Value

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 Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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