pub struct LoadConfig {
pub sources: Vec<SourceDecl>,
pub defs: Vec<String>,
pub links: Vec<(String, Vec<LinkDecl>)>,
}Expand description
装载配置(store.config.json 的 sources + defs + links)
Fields§
§sources: Vec<SourceDecl>保持声明顺序(serde_json::Map 为 BTreeMap ⇒ 字典序;确定性输出)
defs: Vec<String>§links: Vec<(String, Vec<LinkDecl>)>schema 名 → 有序链路声明(保声明序;缺省为空 ⇒ 零回归)
Implementations§
Source§impl LoadConfig
impl LoadConfig
Sourcepub fn from_json(v: &Value) -> Result<Self, String>
pub fn from_json(v: &Value) -> Result<Self, String>
解析 { "sources": { <name>: { kind, databases:[...] } }, "defs": [<root>...], "links": {...} }。
非法即 Err(禁静默兜底;含 kind 白名单、databases 非空、defs 非空、links 六条校验)。
links 缺省 ⇒ 空(零回归);非空时每项须 source 已声明、role 合法、
priority 为整数、恰一条 primary、database 可判(多库须显式给)。
Sourcepub fn source_of_db(&self, db: &str) -> Result<(&SourceDecl, u8), String>
pub fn source_of_db(&self, db: &str) -> Result<(&SourceDecl, u8), String>
db 名 → (连接声明, 语义深度):同一 db 名挂多个连接 ⇒ Err(设计 §5.2)。
深度由 depth_layered 按 kind 决定(PG=2,其余=1)。
Trait Implementations§
Source§impl Clone for LoadConfig
impl Clone for LoadConfig
Source§impl Debug for LoadConfig
impl Debug for LoadConfig
Auto Trait Implementations§
impl Freeze for LoadConfig
impl RefUnwindSafe for LoadConfig
impl Send for LoadConfig
impl Sync for LoadConfig
impl Unpin for LoadConfig
impl UnsafeUnpin for LoadConfig
impl UnwindSafe for LoadConfig
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