Skip to main content

qubit_fs_testkit/
write_scenario.rs

1// =============================================================================
2//    Copyright (c) 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5//
6//    Licensed under the Apache License, Version 2.0.
7// =============================================================================
8//! Provider-neutral write scenarios with fixed contract expectations.
9
10/// The write behavior whose request a fixture prepares.
11///
12/// # Examples
13///
14/// ```
15/// use qubit_fs_testkit::WriteScenario;
16///
17/// assert_eq!(WriteScenario::Create, WriteScenario::Create);
18/// assert_ne!(WriteScenario::Replace, WriteScenario::Append);
19/// ```
20#[must_use]
21#[derive(Clone, Copy, Debug, Eq, PartialEq)]
22pub enum WriteScenario {
23    /// Publish bytes to a previously absent destination.
24    Create,
25    /// Open a fresh CreateNew writer for explicit abort without committing.
26    Abort,
27    /// Attempt CreateNew against an independently seeded existing target.
28    CreateConflict,
29    /// Replace the entire contents of an existing destination.
30    /// The initial contents must be longer than the payload to verify
31    /// truncation.
32    Replace,
33    /// Append bytes to an existing destination.
34    /// Preparation must supply nonempty initial contents for independent
35    /// observation.
36    Append,
37    /// Write with an explicit absence precondition.
38    IfAbsent,
39    /// Write with the current destination version as a precondition.
40    IfMatch,
41    /// Replace an existing destination with required atomicity.
42    /// Initial contents must differ from the requested replacement bytes.
43    AtomicReplace,
44    /// Publish bytes with required durability.
45    /// The prepared request uses CreateNew at a previously absent destination.
46    Durable,
47}