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
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
// property contract tests.
//! Compact immutable sets of provider operation entry points.
use super::ProviderOperation;
/// Immutable set of concrete operation entry points implemented by a provider.
///
/// # Examples
///
/// ```rust
/// use qubit_fs::spi::{ProviderOperation, ProviderOperations};
///
/// let ops = ProviderOperations::new().with(ProviderOperation::Stat);
/// assert!(ops.supports(ProviderOperation::Stat));
/// ```
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct ProviderOperations {
/// Bit flags indexed by [`ProviderOperation`] discriminants.
bits: u128,
}
impl ProviderOperations {
/// Creates an empty provider-operation set.
///
/// # Returns
/// A set containing no provider operation entry points.
#[inline]
#[must_use]
pub const fn new() -> Self {
Self { bits: 0 }
}
/// Returns a copy containing `operation`.
///
/// # Parameters
/// - `operation`: Provider entry point to insert.
///
/// # Returns
/// The updated immutable operation set.
#[inline]
#[must_use]
pub const fn with(mut self, operation: ProviderOperation) -> Self {
self.bits |= 1_u128 << operation as u8;
self
}
/// Returns whether the provider implements `operation`.
///
/// # Parameters
/// - `operation`: Provider entry point to query.
///
/// # Returns
/// `true` when the operation is present in this snapshot.
#[inline]
#[must_use]
pub const fn supports(&self, operation: ProviderOperation) -> bool {
self.bits & (1_u128 << operation as u8) != 0
}
}