pub struct Target(/* private fields */);Expand description
An opaque execution target token.
This was an enum until 0.3.0, and the change is deliberate: the compiler
has no business knowing that a target is called “host”. It compares tokens,
orders them, and folds them into the plan hash — nothing more. The domain
layer names them (ADR 0034), exactly as it already names DomainToken.
THE ORDINALS ARE WIRE. They are folded into graph_id and plan_id as
little-endian u32, and #[serde(transparent)] makes the postcard encoding
byte-identical to the variant indices the enum emitted. The values below are
therefore historically assigned and may never be renumbered.
Debug is wire too, and that is less obvious: KernelDescriptor::lowering
is conventionally built as format!("{target:?}"), and lowering is a
hashed field. The hand-written Debug below reproduces the enum’s output
exactly for that reason; a derived one would print Target(1) and move every
plan id in the fleet without touching an ordinal.
Implementations§
Source§impl Target
impl Target
Sourcepub const BlutDurable: Self
pub const BlutDurable: Self
Historically assigned 2.
Sourcepub const fn token(self) -> u32
pub const fn token(self) -> u32
The wire value. Named token rather than as u32 so that the cast
sites are greppable and cannot be written by accident.
Sourcepub const fn from_token(token: u32) -> Self
pub const fn from_token(token: u32) -> Self
Build a token from a wire value, WITHOUT range checking — decoding
untrusted bytes must call is_known as well. See is_known.
Sourcepub const fn is_known(self) -> bool
pub const fn is_known(self) -> bool
Whether this token is one this version assigns a meaning to.
The enum’s derived Deserialize used to reject an out-of-range variant
index for free. A transparent newtype accepts any u32, so the check
that was implicit is explicit here, and from_aot_bytes calls it.