pub struct Withheld(/* private fields */);Expand description
Capabilities a context is to be built without, as a bitmask.
A set rather than one capability because a test may want a device short of
two things at once, and a bitmask rather than a Vec because
ContextConfig is Copy and a heap field would take that away from a
published type. Hand-rolled over a u32 like SampleCounts above, for the
same reason: this workspace has no bitflags dependency and does not need one.
The name is the type’s only job beyond storage. Nothing here can grant a
capability, and a neutral name like CapabilitySet would invite someone to
add that direction; Withheld makes it unsayable. Self::apply_to can
clear a field and can do nothing else.
Implementations§
Source§impl Withheld
impl Withheld
Sourcepub const fn none() -> Self
pub const fn none() -> Self
Withhold nothing, which is what every ordinary caller wants and what
Default gives.
Sourcepub const fn of(capability: Capability) -> Self
pub const fn of(capability: Capability) -> Self
Withhold exactly one.
Sourcepub const fn with(self, capability: Capability) -> Self
pub const fn with(self, capability: Capability) -> Self
The same set with one more withheld.
Sourcepub const fn contains(self, capability: Capability) -> bool
pub const fn contains(self, capability: Capability) -> bool
Whether this set withholds capability.
Sourcepub fn apply_to(self, capabilities: &mut Capabilities)
pub fn apply_to(self, capabilities: &mut Capabilities)
Clear every withheld capability from capabilities.
Clearing only. A capability already false stays false, so applying this to a device that never had the thing is a no-op rather than a promotion – which is what makes the set safe to apply unconditionally at the end of detection.
A backend that can express a withholding more honestly should do that as well: dropping the extension the capability is backed by means the probe reports false on its own merits and the device is genuinely built without it. This is what covers the fields backed by a format query rather than an extension, and it is the belt to that braces.