pub struct FileSystemCapabilities { /* private fields */ }Expand description
Stable typed capability support for one configured filesystem.
Capabilities have one of two support strengths: conditional capabilities may be attempted and can still be rejected for an individual request, while guaranteed capabilities are promised for every valid request in scope. Derived capabilities must not be stronger than their base capability.
§Examples
use qubit_fs::metadata::{FileSystemCapabilities, FileSystemCapability,
FileSystemCapabilitySupport};
let capabilities = FileSystemCapabilities::new()
.with_conditional(FileSystemCapability::Read)
.with_conditional(FileSystemCapability::RangeRead);
assert_eq!(capabilities.support(FileSystemCapability::RangeRead),
FileSystemCapabilitySupport::Conditional);
assert_eq!(capabilities.support(FileSystemCapability::Write),
FileSystemCapabilitySupport::Unsupported);
assert!(capabilities.missing_dependency().is_none());
let invalid = FileSystemCapabilities::new()
.with_guaranteed(FileSystemCapability::RangeRead)
.with_conditional(FileSystemCapability::Read);
assert_eq!(invalid.missing_dependency(), Some((
FileSystemCapability::RangeRead, FileSystemCapability::Read)));Implementations§
Source§impl FileSystemCapabilities
impl FileSystemCapabilities
Sourcepub const fn with_conditional(self, capability: FileSystemCapability) -> Self
pub const fn with_conditional(self, capability: FileSystemCapability) -> Self
Returns a copy with one additional conditional capability.
§Parameters
capability: Capability that may be attempted but is not guaranteed for every valid request.
Sourcepub const fn with_guaranteed(self, capability: FileSystemCapability) -> Self
pub const fn with_guaranteed(self, capability: FileSystemCapability) -> Self
Returns a copy with one additional guaranteed capability.
§Parameters
capability: Capability promised for every valid request in scope.
Sourcepub const fn set_support(
self,
capability: FileSystemCapability,
support: FileSystemCapabilitySupport,
) -> Self
pub const fn set_support( self, capability: FileSystemCapability, support: FileSystemCapabilitySupport, ) -> Self
Replaces the support status of one capability.
§Parameters
capability: Capability whose current status is replaced.support: New support strength to record for that capability.
Sourcepub const fn support(
&self,
capability: FileSystemCapability,
) -> FileSystemCapabilitySupport
pub const fn support( &self, capability: FileSystemCapability, ) -> FileSystemCapabilitySupport
Returns the support status of capability.
§Parameters
capability: Capability whose advertised support is queried.
Sourcepub const fn supports(&self, capability: FileSystemCapability) -> bool
pub const fn supports(&self, capability: FileSystemCapability) -> bool
Returns whether the provider can attempt capability.
§Parameters
capability: Capability to test for conditional or guaranteed support.
Sourcepub const fn guarantees(&self, capability: FileSystemCapability) -> bool
pub const fn guarantees(&self, capability: FileSystemCapability) -> bool
Returns whether capability is guaranteed in this filesystem scope.
§Parameters
capability: Capability to test for guaranteed support.
Sourcepub fn iter(&self) -> impl Iterator<Item = FileSystemCapability> + '_
pub fn iter(&self) -> impl Iterator<Item = FileSystemCapability> + '_
Iterates advertised capabilities in stable discriminant order.
§Returns
An iterator over every capability contained in this set.
Sourcepub fn iter_with_support(
&self,
) -> impl Iterator<Item = (FileSystemCapability, FileSystemCapabilitySupport)> + '_
pub fn iter_with_support( &self, ) -> impl Iterator<Item = (FileSystemCapability, FileSystemCapabilitySupport)> + '_
Iterates advertised capabilities with their support status.
Sourcepub fn missing_dependency(
&self,
) -> Option<(FileSystemCapability, FileSystemCapability)>
pub fn missing_dependency( &self, ) -> Option<(FileSystemCapability, FileSystemCapability)>
Returns the first advertised capability whose required base capability has insufficient support.
A conditional derived capability requires its base capability to be conditional or guaranteed. A guaranteed derived capability requires a guaranteed base capability. Thus a base capability may be advertised yet still be insufficient. The returned pair contains the derived capability followed by the absent or insufficient base capability.
§Returns
Some with the first derived capability and missing base capability,
or None when no advertised dependency is missing.