qubit-fs-testkit 0.7.1

Reusable provider contract checks for qubit-fs implementations
Documentation
// =============================================================================
//    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 {
    pub(crate) id: ContractCheckId,
    pub(crate) capability: Option<FileSystemCapability>,
    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]
    #[must_use]
    pub const fn capability(&self) -> Option<FileSystemCapability> {
        self.capability
    }

    /// Returns the recorded check outcome.
    #[inline]
    pub const fn outcome(&self) -> &ContractCheckOutcome {
        &self.outcome
    }
}