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
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Stage-aware asynchronous whole-file write cancellation probes.
use std::task::Context;
use std::task::Poll;
use crate::AsyncWriteFixtureCase;
use crate::FixtureFuture;
use crate::FixtureResult;
/// Controls one provider-owned pending stage of an owning write operation.
///
/// # Examples
///
/// ```
/// use qubit_fs::path::Path;
/// use qubit_fs::write::{WriteDisposition, WriteOptions};
/// use qubit_fs_testkit::AsyncWriteFixtureCase;
///
/// let case = AsyncWriteFixtureCase::new(
/// Path::parse("/target")?,
/// b"payload".to_vec(),
/// WriteOptions::default().with_disposition(WriteDisposition::CreateNew),
/// );
/// assert_eq!(case.bytes(), b"payload");
/// # Ok::<(), qubit_fs::error::FsError>(())
/// ```
pub trait WriteCancellationProbe: Send + Sync {
/// Returns the isolated write request controlled by this probe.
fn case(&self) -> &AsyncWriteFixtureCase;
/// Polls until the configured provider stage is pending.
fn poll_reached(&self, context: &mut Context<'_>) -> Poll<FixtureResult<()>>;
/// Returns the independently observed bytes accepted before cancellation.
///
/// Count bytes accepted by the provider writer, including unpublished
/// staging bytes. Opening a writer has accepted zero payload bytes.
fn accepted_bytes(&self) -> FixtureResult<u64>;
/// Observes the target independently of the filesystem under test.
///
/// Return `None` only when absence is confirmed; otherwise return the
/// complete published bytes. Errors must remain errors. The suite compares
/// observations before execution and after a `NotPublished` recovery, so
/// neither a stale cache nor an assumed empty target is sufficient.
fn observe_target(&self) -> FixtureFuture<'_, Option<Vec<u8>>>;
/// Releases the provider gate without performing another filesystem call.
fn disarm(&self) -> FixtureResult<()>;
}