qubit_fs/metadata/file_system_capability.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//! Typed filesystem capability identifiers.
9
10/// A stable operation or semantic guarantee advertised by a filesystem.
11///
12/// # Examples
13///
14/// ```rust
15/// use qubit_fs::metadata::FileSystemCapability;
16///
17/// assert!(matches!(FileSystemCapability::Read, FileSystemCapability::Read));
18/// ```
19#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
20#[repr(u8)]
21#[non_exhaustive]
22pub enum FileSystemCapability {
23 /// Directory or prefix listing.
24 List = 0,
25 /// Sequential byte reads.
26 Read = 1,
27 /// Required byte-range reads.
28 RangeRead = 2,
29 /// Version-conditional reads.
30 ConditionalRead = 3,
31 /// Provider-backed checksum validation for reads.
32 ChecksumValidation = 4,
33 /// File or object writes.
34 Write = 5,
35 /// Append writes.
36 Append = 6,
37 /// Conditional writes.
38 ConditionalWrite = 7,
39 /// Directory creation.
40 CreateDirectory = 8,
41 /// Native empty-directory representation.
42 EmptyDirectory = 9,
43 /// Resource deletion.
44 Delete = 10,
45 /// Recursive directory or prefix deletion.
46 RecursiveDelete = 11,
47 /// Version-conditional deletion.
48 ConditionalDelete = 12,
49 /// Rename or move.
50 Rename = 13,
51 /// Atomic rename.
52 AtomicRename = 14,
53 /// Atomic replacement publication.
54 AtomicReplace = 15,
55 /// Application-visible copy support supplied by a provider `TryCopy`
56 /// operation or the facade's allowlisted stream fallback.
57 Copy = 16,
58 /// Server-side copy without downloading payload bytes.
59 ServerSideCopy = 17,
60 /// Symbolic links.
61 Symlink = 18,
62 /// Native or configured temporary files.
63 TempFile = 19,
64 /// Native or configured temporary directories.
65 TempDirectory = 20,
66 /// Atomic temporary-resource persistence.
67 AtomicTempPersist = 21,
68 /// Atomic publication of a copied regular file or object.
69 AtomicFileCopy = 22,
70 /// Atomic publication of a copied directory tree or prefix.
71 AtomicTreeCopy = 23,
72 /// Durable publication of a copied regular file or object.
73 DurableFileCopy = 24,
74 /// Durable publication of a copied directory tree or prefix.
75 DurableTreeCopy = 25,
76 /// Durable publication of a renamed resource.
77 DurableRename = 26,
78 /// Durable publication of a completed write session.
79 DurableWrite = 27,
80}
81
82impl FileSystemCapability {
83 /// Stable list of every capability known by this crate version.
84 pub const ALL: &'static [Self] = &[
85 Self::List,
86 Self::Read,
87 Self::RangeRead,
88 Self::ConditionalRead,
89 Self::ChecksumValidation,
90 Self::Write,
91 Self::Append,
92 Self::ConditionalWrite,
93 Self::CreateDirectory,
94 Self::EmptyDirectory,
95 Self::Delete,
96 Self::RecursiveDelete,
97 Self::ConditionalDelete,
98 Self::Rename,
99 Self::AtomicRename,
100 Self::AtomicReplace,
101 Self::Copy,
102 Self::ServerSideCopy,
103 Self::Symlink,
104 Self::TempFile,
105 Self::TempDirectory,
106 Self::AtomicTempPersist,
107 Self::AtomicFileCopy,
108 Self::AtomicTreeCopy,
109 Self::DurableFileCopy,
110 Self::DurableTreeCopy,
111 Self::DurableRename,
112 Self::DurableWrite,
113 ];
114
115 /// Returns the bit representing this capability in a capability set.
116 #[inline]
117 pub(crate) const fn bit(self) -> u128 {
118 1_u128 << (self as u8)
119 }
120}