pub struct ZenithConfig {
pub server: ServerConfig,
pub runtime: RuntimeConfig,
pub cache: CacheConfig,
pub security: SecurityConfig,
pub observability: ObservabilityConfig,
}Expand description
Zenith 框架的顶层配置根,聚合全部子配置段。
Fields§
§server: ServerConfig服务器监听与连接相关配置。
runtime: RuntimeConfig运行时线程模型与加速特性配置。
cache: CacheConfig缓存分片与淘汰策略配置。
security: SecurityConfig安全(TLS、常量时间、eBPF 完整性)配置。
observability: ObservabilityConfig可观测性(指标、追踪、日志)配置。
Implementations§
Source§impl ZenithConfig
impl ZenithConfig
Sourcepub fn from_file(path: &Path) -> Result<ZenithConfig, ConfigError>
pub fn from_file(path: &Path) -> Result<ZenithConfig, ConfigError>
从指定文件路径加载并校验配置。
§Errors
- 文件不存在(
ErrorKind::NotFound)→ConfigError::NotFound - 其他文件读取失败 →
ConfigError::Io - TOML 解析失败 →
ConfigError::Toml - 业务校验失败 →
ConfigError::Validation
Sourcepub fn to_toml(&self) -> Result<String, ConfigError>
pub fn to_toml(&self) -> Result<String, ConfigError>
Sourcepub fn save_to_file(&self, path: &Path) -> Result<(), ConfigError>
pub fn save_to_file(&self, path: &Path) -> Result<(), ConfigError>
Sourcepub fn validate(&self) -> Result<(), ConfigError>
pub fn validate(&self) -> Result<(), ConfigError>
Trait Implementations§
Source§impl Clone for ZenithConfig
impl Clone for ZenithConfig
Source§fn clone(&self) -> ZenithConfig
fn clone(&self) -> ZenithConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ZenithConfig
impl Debug for ZenithConfig
Source§impl Default for ZenithConfig
impl Default for ZenithConfig
Source§fn default() -> ZenithConfig
fn default() -> ZenithConfig
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ZenithConfig
impl<'de> Deserialize<'de> for ZenithConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ZenithConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ZenithConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl FromStr for ZenithConfig
通过 std::str::FromStr 从 TOML 字符串加载配置,避免与标准 trait 命名冲突。
impl FromStr for ZenithConfig
通过 std::str::FromStr 从 TOML 字符串加载配置,避免与标准 trait 命名冲突。
Source§type Err = ConfigError
type Err = ConfigError
The associated error which can be returned from parsing.
Source§fn from_str(s: &str) -> Result<ZenithConfig, ConfigError>
fn from_str(s: &str) -> Result<ZenithConfig, ConfigError>
Parses a string
s to return a value of this type. Read moreSource§impl Serialize for ZenithConfig
impl Serialize for ZenithConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for ZenithConfig
impl RefUnwindSafe for ZenithConfig
impl Send for ZenithConfig
impl Sync for ZenithConfig
impl Unpin for ZenithConfig
impl UnsafeUnpin for ZenithConfig
impl UnwindSafe for ZenithConfig
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
Mutably borrows from an owned value. Read more