pub struct Frontmatter { /* private fields */ }Expand description
A concept’s frontmatter: an ordered key/value mapping with typed accessors for the well-known OKF fields.
Implementations§
Source§impl Frontmatter
impl Frontmatter
Sourcepub const fn new() -> Frontmatter
pub const fn new() -> Frontmatter
Creates an empty frontmatter block.
Sourcepub const fn from_mapping(map: Mapping) -> Frontmatter
pub const fn from_mapping(map: Mapping) -> Frontmatter
Wraps an existing mapping.
Sourcepub const fn as_mapping(&self) -> &Mapping
pub const fn as_mapping(&self) -> &Mapping
Borrows the underlying ordered mapping.
Sourcepub const fn as_mapping_mut(&mut self) -> &mut Mapping
pub const fn as_mapping_mut(&mut self) -> &mut Mapping
Mutably borrows the underlying ordered mapping.
Sourcepub fn into_mapping(self) -> Mapping
pub fn into_mapping(self) -> Mapping
Consumes the wrapper, returning the underlying mapping.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
true if frontmatter contains the given key.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&Value, &Value)>
pub fn iter(&self) -> impl Iterator<Item = (&Value, &Value)>
Iterates over frontmatter (key, value) pairs in order.
Sourcepub fn keys(&self) -> impl Iterator<Item = &str>
pub fn keys(&self) -> impl Iterator<Item = &str>
Iterates over frontmatter string keys in order.
Sourcepub fn values(&self) -> impl Iterator<Item = &Value>
pub fn values(&self) -> impl Iterator<Item = &Value>
Iterates over frontmatter values in order.
Sourcepub fn get(&self, key: &str) -> Option<&Value>
pub fn get(&self, key: &str) -> Option<&Value>
Raw value for an arbitrary key (including producer extensions).
Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
Looks up a mutable value by string key.
Sourcepub fn set(&mut self, key: impl Into<String>, value: Value)
pub fn set(&mut self, key: impl Into<String>, value: Value)
Sets a raw value for a key, preserving position if it already exists.
Sourcepub fn remove(&mut self, key: &str) -> Option<Value>
pub fn remove(&mut self, key: &str) -> Option<Value>
Removes a key from frontmatter, returning the removed value if present.
Sourcepub fn reorder_preferred(&mut self)
pub fn reorder_preferred(&mut self)
Reorders the keys into PREFERRED_KEY_ORDER, leaving every other key
after them in its current relative order.
A port of the reference implementation’s _reorder_frontmatter, which it
applies whenever it writes a concept document; call this before
Document::serialize to produce
frontmatter laid out the same way. No key is added, dropped, or
rewritten, so only the serialized order changes.
Sourcepub fn type_(&self) -> Option<Cow<'_, str>>
pub fn type_(&self) -> Option<Cow<'_, str>>
The required type field. None if absent or not a scalar.
Non-string scalars (type: 42) are coerced to their display form, the
way the reference’s str(fm.get("type")) does, rather than read as
None: the spec calls type “a short string”, so a non-string value
is a producer deviation, but a consumer still gets something to
route on rather than treating the concept as typeless.
Sourcepub fn description(&self) -> Option<Cow<'_, str>>
pub fn description(&self) -> Option<Cow<'_, str>>
The optional one-line description.
Sourcepub fn resource(&self) -> Option<Cow<'_, str>>
pub fn resource(&self) -> Option<Cow<'_, str>>
The optional resource URI for the underlying asset.
The optional tags list. Non-string elements are coerced to their
display form; a non-sequence tags value yields an empty vector.
Sourcepub fn sources(&self) -> Vec<Source>
pub fn sources(&self) -> Vec<Source>
The sources entries: the materials this concept derives from.
Sourcepub fn usage_window(&self) -> Option<UsageWindow>
pub fn usage_window(&self) -> Option<UsageWindow>
The shared usage_window that frames every sources[].usage_count.
Sourcepub fn generated(&self) -> Option<Generated>
pub fn generated(&self) -> Option<Generated>
The generated block: how the current content was produced.
Sourcepub fn verified(&self) -> Vec<Verification>
pub fn verified(&self) -> Vec<Verification>
The verified events: who or what has confirmed this content.
A bare { by, at } mapping is returned as a one-element list, as the
spec requires.
Sourcepub fn latest_verification(&self) -> Option<Verification>
pub fn latest_verification(&self) -> Option<Verification>
The verification with the latest parseable at.
Sourcepub fn trust_tier(&self) -> TrustTier
pub fn trust_tier(&self) -> TrustTier
The trust tier derived from verified.
Sourcepub fn content_changed_at(&self) -> Option<DateTimeField>
pub fn content_changed_at(&self) -> Option<DateTimeField>
When the content last meaningfully changed: generated.at,
falling back to a legacy v0.1 timestamp when generated is absent, as
permitted.
Sourcepub fn timestamp(&self) -> Option<Cow<'_, str>>
pub fn timestamp(&self) -> Option<Cow<'_, str>>
The legacy v0.1 timestamp field, superseded by generated.at.
Prefer Frontmatter::content_changed_at, which reads generated.at
first and falls back to this.
Sourcepub fn status(&self) -> Status
pub fn status(&self) -> Status
The lifecycle status. An absent key is Status::Stable.
Sourcepub fn stale_after(&self) -> Option<DateTimeField>
pub fn stale_after(&self) -> Option<DateTimeField>
The stale_after timestamp, on and after which the content is stale.
Sourcepub fn is_stale_at(&self, now: DateTime) -> bool
pub fn is_stale_at(&self, now: DateTime) -> bool
Whether the concept is stale at now: now >= stale_after.
A concept with no (or an unreadable / offset-less) stale_after is never stale.
Sourcepub fn is_stale_on(&self, today: Date) -> bool
pub fn is_stale_on(&self, today: Date) -> bool
Whether the concept is stale on today: today >= stale_after.
Evaluates staleness at midnight UTC on today.
Sourcepub fn is_attested_computation(&self) -> bool
pub fn is_attested_computation(&self) -> bool
true when type is Attested Computation.
Sourcepub fn runtime(&self) -> Option<Cow<'_, str>>
pub fn runtime(&self) -> Option<Cow<'_, str>>
The runtime: how to run the computation, and so what parameters
mean. REQUIRED on an Attested Computation concept.
Sourcepub fn parameters(&self) -> Vec<Parameter>
pub fn parameters(&self) -> Vec<Parameter>
The declared parameters an agent may fill.
Sourcepub fn computation(&self) -> Option<Cow<'_, str>>
pub fn computation(&self) -> Option<Cow<'_, str>>
The computation path, when the computation lives in a file rather than
a body block.
Sourcepub fn executor(&self) -> Option<Executor>
pub fn executor(&self) -> Option<Executor>
The executor: how the computation is run, and what a receipt carries.
Sourcepub fn attester(&self) -> Option<Attester>
pub fn attester(&self) -> Option<Attester>
The attester: deterministic code that turns a receipt into a verdict.
Sourcepub fn path_fields(&self) -> Vec<(&'static str, String)>
pub fn path_fields(&self) -> Vec<(&'static str, String)>
The path-valued frontmatter fields present, as
(field name, raw value).
sources[].resource is deliberately excluded: it may be a scope
descriptor rather than a path. Use
Source::resource_kind to
filter those yourself.
Sourcepub fn extension_keys(&self) -> Vec<&str>
pub fn extension_keys(&self) -> Vec<&str>
Returns the keys present that are not well-known OKF fields, i.e. the producer-defined extension keys consumers must preserve.
Sourcepub fn legacy_keys(&self) -> Vec<&str>
pub fn legacy_keys(&self) -> Vec<&str>
Returns the legacy v0.1 keys present that v0.2 supersedes.
Trait Implementations§
Source§impl Clone for Frontmatter
impl Clone for Frontmatter
Source§fn clone(&self) -> Frontmatter
fn clone(&self) -> Frontmatter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Frontmatter
impl Debug for Frontmatter
Source§impl Default for Frontmatter
impl Default for Frontmatter
Source§fn default() -> Frontmatter
fn default() -> Frontmatter
Source§impl Display for Frontmatter
impl Display for Frontmatter
Source§impl<'a> Extend<(&'a str, Value)> for Frontmatter
impl<'a> Extend<(&'a str, Value)> for Frontmatter
Source§fn extend<T>(&mut self, iter: T)
fn extend<T>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<(String, Value)> for Frontmatter
impl Extend<(String, Value)> for Frontmatter
Source§fn extend<T>(&mut self, iter: T)
fn extend<T>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Extend<(Value, Value)> for Frontmatter
impl Extend<(Value, Value)> for Frontmatter
Source§fn extend<T>(&mut self, iter: T)
fn extend<T>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl From<Frontmatter> for Mapping
impl From<Frontmatter> for Mapping
Source§fn from(fm: Frontmatter) -> Mapping
fn from(fm: Frontmatter) -> Mapping
Source§impl From<Mapping> for Frontmatter
impl From<Mapping> for Frontmatter
Source§fn from(map: Mapping) -> Frontmatter
fn from(map: Mapping) -> Frontmatter
Source§impl<'a> FromIterator<(&'a str, Value)> for Frontmatter
impl<'a> FromIterator<(&'a str, Value)> for Frontmatter
Source§fn from_iter<T>(iter: T) -> Frontmatter
fn from_iter<T>(iter: T) -> Frontmatter
Source§impl FromIterator<(String, Value)> for Frontmatter
impl FromIterator<(String, Value)> for Frontmatter
Source§fn from_iter<T>(iter: T) -> Frontmatter
fn from_iter<T>(iter: T) -> Frontmatter
Source§impl FromIterator<(Value, Value)> for Frontmatter
impl FromIterator<(Value, Value)> for Frontmatter
Source§fn from_iter<T>(iter: T) -> Frontmatter
fn from_iter<T>(iter: T) -> Frontmatter
Source§impl FromStr for Frontmatter
impl FromStr for Frontmatter
Source§type Err = DocumentError
type Err = DocumentError
Source§fn from_str(s: &str) -> Result<Frontmatter, <Frontmatter as FromStr>::Err>
fn from_str(s: &str) -> Result<Frontmatter, <Frontmatter as FromStr>::Err>
s to return a value of this type. Read moreSource§impl PartialEq for Frontmatter
impl PartialEq for Frontmatter
impl StructuralPartialEq for Frontmatter
Auto Trait Implementations§
impl Freeze for Frontmatter
impl RefUnwindSafe for Frontmatter
impl Send for Frontmatter
impl Sync for Frontmatter
impl Unpin for Frontmatter
impl UnsafeUnpin for Frontmatter
impl UnwindSafe for Frontmatter
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<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 moreSource§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)
Source§impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
fn saturating_into(self) -> U
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more