pub struct Contract {
pub stages: Stage,
pub platform: Platform,
pub sources: Source,
pub scopes: Vec<Scope>,
}Expand description
契约模块 — 适配层,委托给 quanttide-devops toolkit。
完整契约,对应 .quanttide/devops/contract.yaml。
按四维架构组织:Stage(时序)、Platform(载体)、Source(事实源)、Scope(边界)。
Fields§
§stages: Stage§platform: Platform§sources: Source§scopes: Vec<Scope>Implementations§
Source§impl Contract
impl Contract
Sourcepub fn scope_release<'a>(&'a self, scope: &'a Scope) -> &'a StageRelease
pub fn scope_release<'a>(&'a self, scope: &'a Scope) -> &'a StageRelease
获取 scope 的发布配置(scope 级覆盖 → 全局默认)。
Sourcepub fn scope_test_threshold(&self, scope: &Scope) -> f64
pub fn scope_test_threshold(&self, scope: &Scope) -> f64
获取 scope 的测试阈值。
Sourcepub fn find_scope_by_path(&self, current_dir: &Path) -> Option<&Scope>
pub fn find_scope_by_path(&self, current_dir: &Path) -> Option<&Scope>
根据路径查找匹配的 scope(最长前缀匹配)。
例如当前在 src/cli/sub 时,cli scope(dir: src/cli)
比 root scope(dir: .)优先级高。
Sourcepub fn resolve_language(&self, scope: &Scope, scope_dir: &Path) -> Language
pub fn resolve_language(&self, scope: &Scope, scope_dir: &Path) -> Language
语言探测:scope 声明了具体语言则返回,否则按目录文件推测。
Sourcepub fn validate(&self, repo_path: &Path) -> Vec<String>
pub fn validate(&self, repo_path: &Path) -> Vec<String>
验算契约:检查 scope 配置是否合法。
返回所有问题的描述列表,空表示合法。
use std::path::Path;
use quanttide_devops::contract::Contract;
let c = Contract::default();
let errors = c.validate(Path::new("/tmp/nonexistent"));
assert!(errors.is_empty()); // 空契约→无 scope 可检查Sourcepub fn auto_detect(repo_path: &Path) -> Contract
pub fn auto_detect(repo_path: &Path) -> Contract
根据目录下的配置文件自动推测仓库结构,生成契约。
扫描 src/、packages/、apps/ 下的子目录,检测每个子目录的编程语言并创建 scope。
如果根目录也存在已知配置文件,添加一个 (root) scope。
use std::path::Path;
use quanttide_devops::contract::Contract;
let c = Contract::auto_detect(Path::new("/tmp/nonexistent"));
assert!(c.scopes.is_empty());Trait Implementations§
Source§impl<'de> Deserialize<'de> for Contract
impl<'de> Deserialize<'de> for Contract
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Contract, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Contract, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Contract
impl Serialize for Contract
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 Contract
impl RefUnwindSafe for Contract
impl Send for Contract
impl Sync for Contract
impl Unpin for Contract
impl UnsafeUnpin for Contract
impl UnwindSafe for Contract
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