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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Checks expected opening rejections without losing isolated recovery
//! ownership.
use FsErrorKind;
use FsOperation;
use OpenFailure;
use OpenFailureStage;
use FileSystemCapability;
use Path;
use crateContractCheckId;
use crateContractFailure;
/// Accepts only the expected rejection before an envelope was returned.
///
/// Unexpected context, stage, or recovery ownership produces a contract failure
/// retaining the complete original opening failure. Callers can take its source
/// and explicitly recover; validation never silently drops an isolated session.
///
/// # Type Parameters
///
/// * `R` — the recovery resource type owned by the opening failure. It must be
/// transferable between threads and live for the `'static` lifetime so the
/// complete failure can be retained as a contract failure source.
///
/// # Parameters
///
/// * `failure` — the opening failure to validate and retain on mismatch.
/// * `kind` — the required filesystem error kind.
/// * `operation` — the filesystem operation that was expected to fail.
/// * `path` — the path at which the operation was expected to fail.
/// * `provider` — the provider name expected when the error identifies one.
/// * `capability` — the required capability recorded by the error, if any.
/// * `check` — the contract check identifier attached to a mismatch.
///
/// # Errors
///
/// Returns a [`ContractFailure`] containing the original `failure` when its
/// stage, recovery ownership, or error context differs from the expected
/// rejection.
pub