pub struct ChainConfigRegistry { /* private fields */ }Expand description
Resolves the full configuration of custom chains by name.
Built-in chains are resolved without this registry; it only holds user-defined chains loaded
from a YAML source. Build it explicitly via ChainConfigRegistry::from_configs,
ChainConfigRegistry::from_yaml_file, or ChainConfigRegistry::load_default, then install
it as the process-wide registry with init_chain_registry.
Implementations§
Source§impl ChainConfigRegistry
impl ChainConfigRegistry
Sourcepub fn from_configs(
configs: impl IntoIterator<Item = CustomChainConfig>,
) -> Result<Self, ChainConfigError>
pub fn from_configs( configs: impl IntoIterator<Item = CustomChainConfig>, ) -> Result<Self, ChainConfigError>
Builds a registry from custom chain configs, keyed by chain name. Rejects duplicate names
with ChainConfigError::DuplicateChain rather than silently overriding, so an ambiguous
config fails loudly at construction.
Sourcepub fn load_default() -> Result<Self, ChainConfigError>
pub fn load_default() -> Result<Self, ChainConfigError>
Reads custom chain configs from the path in TYCHO_CHAINS_CONFIG.
Returns an empty registry when the env var is unset, so runs on built-in chains need no
config. When it is set, the file is loaded as-is: a missing, unreadable, or malformed file
is an error (the operator asked for a config, so a broken one is a mistake, not “no custom
chains”), leaving the caller to decide how to react. Install the result with
init_chain_registry to make it the process-wide registry.
Sourcepub fn load_default_or_empty() -> Self
pub fn load_default_or_empty() -> Self
Like load_default but never fails: a broken TYCHO_CHAINS_CONFIG
(missing, unreadable, or malformed file) is logged and degrades to an empty registry rather
than aborting. Used by chain_registry to lazily initialise the process-wide registry, so
a consumer only needs to set TYCHO_CHAINS_CONFIG — no explicit init call. Call
load_default directly when you need to react to the error.
Sourcepub fn from_yaml_file(path: &str) -> Result<Self, ChainConfigError>
pub fn from_yaml_file(path: &str) -> Result<Self, ChainConfigError>
Parses a registry from a YAML file with a top-level chains: list.
Sourcepub fn from_yaml_str(contents: &str) -> Result<Self, ChainConfigError>
pub fn from_yaml_str(contents: &str) -> Result<Self, ChainConfigError>
Parses a registry from a YAML string with a top-level chains: list.
Sourcepub fn get(&self, name: &str) -> Option<&CustomChainConfig>
pub fn get(&self, name: &str) -> Option<&CustomChainConfig>
Returns the config for a custom chain by name, if registered.
Trait Implementations§
Source§impl Clone for ChainConfigRegistry
impl Clone for ChainConfigRegistry
Source§fn clone(&self) -> ChainConfigRegistry
fn clone(&self) -> ChainConfigRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChainConfigRegistry
impl Debug for ChainConfigRegistry
Source§impl Default for ChainConfigRegistry
impl Default for ChainConfigRegistry
Source§fn default() -> ChainConfigRegistry
fn default() -> ChainConfigRegistry
Auto Trait Implementations§
impl Freeze for ChainConfigRegistry
impl RefUnwindSafe for ChainConfigRegistry
impl Send for ChainConfigRegistry
impl Sync for ChainConfigRegistry
impl Unpin for ChainConfigRegistry
impl UnsafeUnpin for ChainConfigRegistry
impl UnwindSafe for ChainConfigRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more