Expand description
Which capturable aspects to collect.
A capture set names the aspects that can be read off the calling thread.
Declared aspects are not in this vocabulary at all: there is nothing to
collect for them, so they are stated by the caller instead – see
crate::declared.
§There is deliberately no Default implementation
The default set is a named constant, CaptureSet::DEFAULT, which a
caller must name to get.
That is not ceremony. The workspace decision that this composite is exhaustively enumerated rests on its field list being contract surface: a silently added field is a silent semantic change. An implicit default has the same property in a worse form, because growing it changes behaviour for callers who never named it and have no diff to review. Naming it makes growth a visible change to a named thing, lets a caller who wants stability list aspects explicitly, and gives a caller who takes the default somewhere to go and read what it contains.
§Example
use windows_thread_ambient_sys::capture_set::{CaptureSet, CapturableAspect};
// The default is opted into by name, never inherited by accident.
let set = CaptureSet::DEFAULT;
assert!(set.contains(CaptureSet::IMPERSONATION));
// TxF is excluded from the default; ask for it deliberately.
assert!(!set.contains(CaptureSet::TRANSACTION));
let with_txf = set.union(CaptureSet::TRANSACTION);
assert!(with_txf.contains(CaptureSet::TRANSACTION));
// A caller that wants stability names its aspects rather than taking a set
// whose membership may grow.
let pinned = CaptureSet::IMPERSONATION.union(CaptureSet::ERROR_MODE);
assert_eq!(pinned.aspects().count(), 2);
assert!(pinned.aspects().any(|a| a == CapturableAspect::ErrorMode));Structs§
- Capture
Set - Which capturable aspects a capture should collect.
Enums§
- Capturable
Aspect - One aspect that can be read off the calling thread.