Skip to main content

Tag

Enum Tag 

Source
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: TaxonomyAxis

Taxonomy axis (hardware / software / devices / dataforts).

§key: String

Key portion after the <axis>. prefix (e.g. gpu).

§

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: TaxonomyAxis

Taxonomy axis.

§key: String

Key portion (everything between <axis>. and the separator).

§value: String

Value portion (everything after the separator).

§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: String

One of RESERVED_PREFIXES (e.g. causal:).

§body: String

Tag content after the reserved prefix.

§

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

Source

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).

Source

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.

Source

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.

Source

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).

Source

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.”)

Source

pub fn reserved_body(&self) -> Option<&str>

Body of a reserved-prefix tag (e.g. <hex> from causal:<hex>). None for non-reserved variants.

Source

pub fn reserved_prefix(&self) -> Option<&str>

Reserved-prefix string (causal:, scope:, etc.) for reserved-variant tags. None otherwise.

Source

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.

Source

pub fn axis(&self) -> Option<TaxonomyAxis>

Axis of an axis tag (AxisPresent / AxisValue). None for reserved + legacy tags.

Source

pub fn to_wire(&self) -> String

Canonical wire string. Mirrors fmt::Display.

Source

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 Clone for Tag

Source§

fn clone(&self) -> Tag

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tag

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Tag

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Tag, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Tag

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Tag

Source§

impl Hash for Tag

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Tag

Source§

fn cmp(&self, other: &Tag) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Tag

Source§

fn eq(&self, other: &Tag) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Tag

Source§

fn partial_cmp(&self, other: &Tag) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Tag

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CallHasher for T
where T: Hash + ?Sized,

Source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more