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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Owned write requests prepared independently of the operation under test.
use qubit_fs::path::Path;
use qubit_fs::write::WriteOptions;
/// A write request; its expected behavior is determined by `WriteScenario`.
///
/// Fixtures supply representable requests, never weaker expected results.
///
/// # Examples
///
/// ```
/// use qubit_fs::path::Path;
/// use qubit_fs::write::{WriteDisposition, WriteOptions};
/// use qubit_fs_testkit::WriteFixtureCase;
///
/// let request = WriteFixtureCase::new(
/// Path::parse("/isolated/write")?,
/// b"payload".to_vec(),
/// WriteOptions::default().with_disposition(WriteDisposition::CreateNew),
/// );
/// assert_eq!(request.bytes(), b"payload");
/// # Ok::<(), qubit_fs::error::FsError>(())
/// ```
#[must_use]
#[derive(Clone, Debug)]
pub struct WriteFixtureCase {
/// Destination path passed to the write operation.
path: Path,
/// Owned payload the suite will verify independently.
bytes: Vec<u8>,
/// Requested disposition, preconditions, and guarantees.
options: WriteOptions,
}
impl WriteFixtureCase {
/// Creates an owned request for the selected scenario.
///
/// # Parameters
///
/// * `path` - destination path owned by the request.
/// * `bytes` - payload owned for independent verification.
/// * `options` - requested disposition, preconditions, and guarantees.
///
/// # Returns
///
/// The request retaining all three supplied values.
#[inline]
pub fn new(path: Path, bytes: Vec<u8>, options: WriteOptions) -> Self {
Self { path, bytes, options }
}
/// Returns the destination mapped into the fixture's isolated namespace.
///
/// # Returns
///
/// A borrow of the destination path stored in this request.
#[must_use = "the destination path should be inspected before the request is used"]
#[inline]
pub const fn path(&self) -> &Path {
&self.path
}
/// Returns the payload the suite will verify independently.
///
/// # Returns
///
/// A borrow of the bytes stored in this request.
#[must_use]
#[inline]
pub fn bytes(&self) -> &[u8] {
&self.bytes
}
/// Returns the requested disposition, preconditions, and guarantees.
///
/// # Returns
///
/// A borrow of the write options stored in this request.
#[must_use = "the write options should be inspected before the request is used"]
#[inline]
pub const fn options(&self) -> &WriteOptions {
&self.options
}
}