1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Stable identity and outcome for one contract check.
use qubit_fs::metadata::FileSystemCapability;
use crate::ContractCheckId;
use crate::ContractCheckOutcome;
/// One named check in a contract report.
///
/// # Examples
///
/// ```
/// # mod support { include!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/common/rustdoc_support.rs")); }
/// # use support::RustdocSyncFixture;
/// use qubit_fs_testkit::{ContractCheckOutcome, FileSystemContract, FileSystemContractSuite};
///
/// let fixture = RustdocSyncFixture::new();
/// let mut suite = FileSystemContractSuite::new(&fixture);
/// suite.run_contract(FileSystemContract::Properties);
/// let check = &suite.run().report().checks()[0];
/// assert!(matches!(check.outcome(), ContractCheckOutcome::Passed | ContractCheckOutcome::Failed { .. }));
/// ```
#[must_use]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ContractCheck {
/// Stable identifier used to correlate this check across reports.
pub(crate) id: ContractCheckId,
/// Capability required by the check, if it depends on one.
pub(crate) capability: Option<FileSystemCapability>,
/// Outcome recorded after evaluating the check.
pub(crate) outcome: ContractCheckOutcome,
}
impl ContractCheck {
/// Returns the stable check identifier.
#[inline]
pub const fn id(&self) -> ContractCheckId {
self.id
}
/// Returns the capability associated with this check, when one exists.
#[inline]
pub const fn capability(&self) -> Option<FileSystemCapability> {
self.capability
}
/// Returns the recorded check outcome.
#[must_use = "the recorded outcome should be inspected"]
#[inline]
pub const fn outcome(&self) -> &ContractCheckOutcome {
&self.outcome
}
}