pub struct CaseId(pub Ulid);Expand description
A long-lived, correlated business fact spanning many runs and weeks.
§One spelling, everywhere
Prefixed (case_01J8Z…) in every direction:
Display, Serialize, the store key, the
column. An id is self-describing wherever it lands — a log line, a
URL, a JSON field, a SIEM — and grepping one against another finds
it whichever way round you do it.
What this rules out is a store spelling one id two ways — prefixed in its keys and bare in its payloads — which costs a consumer an afternoon and looks like two ids until it does.
Deserialize and parse accept a bare ULID too,
because one arrives from somewhere else often enough. The prefix is
checked rather than stripped blindly, so a case_… string is refused
where a RunId is wanted instead of silently becoming one.
Tuple Fields§
§0: UlidImplementations§
Source§impl CaseId
impl CaseId
Sourcepub fn generate() -> Self
pub fn generate() -> Self
Mint a fresh id from the ambient clock and a random tail.
Reserved for the runtime’s admission path, which journals the
result. Skills must never call this — see clippy.toml.
Sorted to the millisecond, not beyond it. Ordering comes from the timestamp prefix, so two ids minted in the same millisecond order by their random tails — arbitrarily, and differently on each instance. A range scan over one run’s records is exact because the run id is a prefix; “cases sort by creation time” is true between milliseconds and a coin flip inside one.
Sourcepub fn parse(s: &str) -> Result<Self, DecodeError>
pub fn parse(s: &str) -> Result<Self, DecodeError>
Reconstruct from a stored string.
Accepts both the prefixed form produced by std::fmt::Display
and a bare ULID, so ids round-trip through logs, URLs, and
database columns without the caller having to know which form it
is holding.
Only the canonical spelling: uppercase Crockford base32 whose
first character is at most 7. The decoder also reads
lowercase, and a first character past 7 overflows 128 bits
and wraps, so without this one id would have many spellings —
and every index keyed on the string would hold a different run
for each.
§Errors
If what remains after the prefix is not a ULID in its canonical spelling.
Trait Implementations§
impl Copy for CaseId
Source§impl<'de> Deserialize<'de> for CaseId
Through parse, so a bare ULID from somewhere else
still reads.
impl<'de> Deserialize<'de> for CaseId
Through parse, so a bare ULID from somewhere else
still reads.
A refusal names the type and the input: ulid’s own error is
invalid length, which says nothing about which field was wrong or
what it wanted.
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
impl Eq for CaseId
Source§impl FromStr for CaseId
The trait an id arrives through: an axum path segment, a clap
argument, a TOML key, a serde field with #[serde(with = …)].
impl FromStr for CaseId
The trait an id arrives through: an axum path segment, a clap
argument, a TOML key, a serde field with #[serde(with = …)].
.parse() is where every consumer reaches first, and its absence
made parse something each of them had to find.
Source§impl JsonSchema for CaseId
The written form: the prefix, an underscore, and a ULID.
impl JsonSchema for CaseId
The written form: the prefix, an underscore, and a ULID.
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§fn json_schema(_: &mut SchemaGenerator) -> Schema
fn json_schema(_: &mut SchemaGenerator) -> Schema
Source§impl Ord for CaseId
impl Ord for CaseId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for CaseId
impl PartialOrd for CaseId
impl StructuralPartialEq for CaseId
Auto Trait Implementations§
impl Freeze for CaseId
impl RefUnwindSafe for CaseId
impl Send for CaseId
impl Sync for CaseId
impl Unpin for CaseId
impl UnsafeUnpin for CaseId
impl UnwindSafe for CaseId
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more