Skip to main content

ConfigReader

Struct ConfigReader 

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

A configuration reader over a MultiLevelMap, with ${...} substitution.

Implementations§

Source§

impl ConfigReader

Source

pub fn load(path: &str) -> Result<Self, ConfigError>

Load a configuration file and resolve references (Java new ConfigReader(path)).

Source

pub fn load_raw(path: &str) -> Result<Self, ConfigError>

Load a configuration file without resolving references (Java load(path, false) — used while merging base configuration files).

Source

pub fn from_yaml_text(text: &str) -> Result<Self, ConfigError>

Build a reader from in-memory YAML text and resolve references — used for embedded built-in templates (e.g. default-log-context.yaml), the Rust analog of a library-jar classpath resource. The resources/ roots are application-owned in this port, so a library default ships compiled-in via include_str! instead of shadowing a file name.

Source

pub fn from_map(map: BTreeMap<String, ConfigValue>) -> Self

Build a reader from an existing nested map and resolve references (Java load(Map)).

Source

pub fn get(&self, key: &str) -> Option<ConfigValue>

Retrieve a value by composite key. None for a missing key, an explicit null, or an unresolvable ${...} reference (Java returns null in each case).

Source

pub fn get_or(&self, key: &str, default: ConfigValue) -> ConfigValue

Retrieve a value by composite key with a default (Java get(key, defaultValue)).

Source

pub fn get_property(&self, key: &str) -> Option<String>

Retrieve a value enforced as a string (Java getProperty).

Source

pub fn get_property_or(&self, key: &str, default: &str) -> String

Retrieve a value enforced as a string, with a default (Java getProperty(key, default)).

Source

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

True when the key resolves to a non-null value (Java exists).

Source

pub fn is_empty(&self) -> bool

Source

pub fn get_map(&self) -> &MultiLevelMap

The raw underlying tree, without substitution (Java getMap).

Source

pub fn get_composite_key_values(&self) -> &BTreeMap<String, ConfigValue>

Flat map of composite key-values with substitution applied, computed once and cached (Java getCompositeKeyValues).

Source

pub fn is_base_config(&self) -> bool

Trait Implementations§

Source§

impl Debug for ConfigReader

Source§

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

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

impl Default for ConfigReader

Source§

fn default() -> Self

Returns the “default value” for a type. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V