pub enum Tag {
AxisPresent {
axis: TaxonomyAxis,
key: String,
},
AxisValue {
axis: TaxonomyAxis,
key: String,
value: String,
separator: AxisSeparator,
},
Reserved {
prefix: String,
body: String,
},
Legacy(String),
}Expand description
Parsed capability tag.
Internal representation; the wire format is the canonical string
returned by fmt::Display. Custom Serialize / Deserialize
impls below render Tag → string and parse string → Tag, so a
HashSet<Tag> rides over the wire as a JSON string array
(["hardware.gpu", "scope:tenant:foo", ...]). The internal
enum shape is an implementation detail callers don’t see.
Parser is permissive — see module docs for the
parse (internal) vs. parse_user (application) split.
Variants§
AxisPresent
Axis-prefixed presence tag with no value.
Wire form: <axis>.<key> (e.g. hardware.gpu).
Fields
axis: TaxonomyAxisTaxonomy axis (hardware / software / devices / dataforts).
AxisValue
Axis-prefixed keyed value. The separator is captured so the
canonical Display round-trips byte-for-byte: some keys use =
(e.g. hardware.gpu.vram_gb=80); the dataforts subset uses :
(e.g. dataforts.has_chain:<hex>).
Fields
axis: TaxonomyAxisTaxonomy axis.
separator: AxisSeparator= or : — captured so wire form round-trips byte-for-byte.
Reserved
Reserved cross-axis prefix (causal:, fork-of:, heat:,
scope:). Stored as (prefix, body) so the parser can route
per-prefix at probe time without re-scanning.
Fields
prefix: StringOne of RESERVED_PREFIXES (e.g. causal:).
Legacy(String)
Legacy pre-Warriors untyped tag. Parses with deprecation
warning; one minor version of compatibility per
CAPABILITY_SYSTEM_PLAN.md Locked decision 1.
Implementations§
Source§impl Tag
impl Tag
Sourcepub fn parse(s: &str) -> Result<Tag, CapabilityTagError>
pub fn parse(s: &str) -> Result<Tag, CapabilityTagError>
Permissive parser: accepts every wire-form shape including
reserved-prefix tags. Used by deserialization and by substrate
code that has authority to emit reserved-prefix tags. Returns
CapabilityTagError::Empty only on the empty string;
otherwise produces some valid Tag variant (legacy if no
shape recognized).
Sourcepub fn parse_user(s: &str) -> Result<Tag, CapabilityTagError>
pub fn parse_user(s: &str) -> Result<Tag, CapabilityTagError>
Application-facing parser: rejects reserved-prefix tags with
CapabilityTagError::ReservedPrefix. Use this in user-code
builders (e.g. CapabilitySet::add_tag) so reserved-prefix
emission is caught at the source rather than corrupting the
substrate’s view of who’s authoritative for causal: etc.
Sourcepub fn axis_key(&self) -> Option<TagKey>
pub fn axis_key(&self) -> Option<TagKey>
(axis, key) extraction for Predicate evaluation. Returns
None for Reserved and Legacy tags (which don’t fit the
axis taxonomy by construction).
Allocates: the returned TagKey owns its key string. Hot
paths that iterate a tag set should prefer Self::axis_key_ref
— see docs/misc/PERF_AUDIT_2026_05_28_CAPABILITY.md for the
per-tag allocation cost this avoids.
Sourcepub fn axis_key_ref(&self) -> Option<(TaxonomyAxis, &str)>
pub fn axis_key_ref(&self) -> Option<(TaxonomyAxis, &str)>
Borrowing counterpart to Self::axis_key — returns
(axis, &key) without cloning the key string. Prefer this in
iteration / predicate hot paths; the cloning variant is only
worth it when the caller actually needs an owned TagKey
(e.g. collecting into a HashSet<TagKey> for diff).
Sourcepub fn value(&self) -> Option<&str>
pub fn value(&self) -> Option<&str>
Value half of a keyed axis tag. Returns None for presence
tags, reserved tags, and legacy tags. (Reserved tags have a
body accessible via Tag::reserved_body; semantically
distinct from “axis value.”)
Sourcepub fn reserved_body(&self) -> Option<&str>
pub fn reserved_body(&self) -> Option<&str>
Body of a reserved-prefix tag (e.g. <hex> from
causal:<hex>). None for non-reserved variants.
Sourcepub fn reserved_prefix(&self) -> Option<&str>
pub fn reserved_prefix(&self) -> Option<&str>
Reserved-prefix string (causal:, scope:, etc.) for
reserved-variant tags. None otherwise.
Sourcepub fn is_legacy(&self) -> bool
pub fn is_legacy(&self) -> bool
true if this is a legacy untyped tag — useful for emitting
the per-process deprecation log when the tag set is built.
Sourcepub fn axis(&self) -> Option<TaxonomyAxis>
pub fn axis(&self) -> Option<TaxonomyAxis>
Axis of an axis tag (AxisPresent / AxisValue). None for
reserved + legacy tags.
Sourcepub fn to_wire(&self) -> String
pub fn to_wire(&self) -> String
Canonical wire string. Mirrors fmt::Display.
Sourcepub fn semantic_eq(&self, other: &Tag) -> bool
pub fn semantic_eq(&self, other: &Tag) -> bool
Semantic equality — like PartialEq but ignores the
= vs : separator on AxisValue. Two tags that only
differ in their wire-form separator describe the same
(axis, key, value) and should compare equal for
membership / require / diff purposes.
PartialEq itself stays separator-aware so the wire
form round-trips byte-for-byte; callers comparing for
meaning (rather than for bytes) should prefer this
method. See CODE_REVIEW_2026_05_10_CAPABILITY_SYSTEM_2.md
CR-1..CR-3 for the bug class this guards against.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Tag
impl<'de> Deserialize<'de> for Tag
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Tag, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Tag, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Eq for Tag
Source§impl Ord for Tag
impl Ord for Tag
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Tag
impl PartialOrd for Tag
Source§impl Serialize for Tag
impl Serialize for Tag
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for Tag
Auto Trait Implementations§
impl Freeze for Tag
impl RefUnwindSafe for Tag
impl Send for Tag
impl Sync for Tag
impl Unpin for Tag
impl UnsafeUnpin for Tag
impl UnwindSafe for Tag
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.