Skip to main content

qubit_fs/write/
write_precondition.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//! Preconditions for opening and committing writes.
9
10use crate::metadata::ResourceVersion;
11
12/// Version precondition applied to a write operation.
13///
14/// # Examples
15///
16/// ```rust
17/// use qubit_fs::write::WritePrecondition;
18///
19/// assert!(matches!(WritePrecondition::None, WritePrecondition::None));
20/// ```
21#[derive(Clone, Debug, Default, Eq, PartialEq)]
22pub enum WritePrecondition {
23    /// Do not require a version precondition.
24    #[default]
25    None,
26    /// Require that no destination exists.
27    IfAbsent,
28    /// Require the destination to have the supplied version.
29    IfMatch(
30        /// Resource version that must match the current destination.
31        ResourceVersion,
32    ),
33}