Skip to main content

Frontmatter

Struct Frontmatter 

Source
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

Source

pub const fn new() -> Frontmatter

Creates an empty frontmatter block.

Source

pub const fn from_mapping(map: Mapping) -> Frontmatter

Wraps an existing mapping.

Source

pub const fn as_mapping(&self) -> &Mapping

Borrows the underlying ordered mapping.

Source

pub const fn as_mapping_mut(&mut self) -> &mut Mapping

Mutably borrows the underlying ordered mapping.

Source

pub fn into_mapping(self) -> Mapping

Consumes the wrapper, returning the underlying mapping.

Source

pub const fn len(&self) -> usize

Number of frontmatter keys.

Source

pub const fn is_empty(&self) -> bool

true if there are no keys.

Source

pub fn contains_key(&self, key: &str) -> bool

true if frontmatter contains the given key.

Source

pub fn iter(&self) -> impl Iterator<Item = (&Value, &Value)>

Iterates over frontmatter (key, value) pairs in order.

Source

pub fn keys(&self) -> impl Iterator<Item = &str>

Iterates over frontmatter string keys in order.

Source

pub fn values(&self) -> impl Iterator<Item = &Value>

Iterates over frontmatter values in order.

Source

pub fn get(&self, key: &str) -> Option<&Value>

Raw value for an arbitrary key (including producer extensions).

Source

pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>

Looks up a mutable value by string key.

Source

pub fn set(&mut self, key: impl Into<String>, value: Value)

Sets a raw value for a key, preserving position if it already exists.

Source

pub fn remove(&mut self, key: &str) -> Option<Value>

Removes a key from frontmatter, returning the removed value if present.

Source

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.

Source

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.

Source

pub fn title(&self) -> Option<Cow<'_, str>>

The optional title field.

Source

pub fn description(&self) -> Option<Cow<'_, str>>

The optional one-line description.

Source

pub fn resource(&self) -> Option<Cow<'_, str>>

The optional resource URI for the underlying asset.

Source

pub fn tags(&self) -> Vec<String>

The optional tags list. Non-string elements are coerced to their display form; a non-sequence tags value yields an empty vector.

Source

pub fn sources(&self) -> Vec<Source>

The sources entries: the materials this concept derives from.

Source

pub fn usage_window(&self) -> Option<UsageWindow>

The shared usage_window that frames every sources[].usage_count.

Source

pub fn generated(&self) -> Option<Generated>

The generated block: how the current content was produced.

Source

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.

Source

pub fn latest_verification(&self) -> Option<Verification>

The verification with the latest parseable at.

Source

pub fn trust_tier(&self) -> TrustTier

The trust tier derived from verified.

Source

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.

Source

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.

Source

pub fn status(&self) -> Status

The lifecycle status. An absent key is Status::Stable.

Source

pub fn stale_after(&self) -> Option<DateTimeField>

The stale_after timestamp, on and after which the content is stale.

Source

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.

Source

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.

Source

pub fn is_attested_computation(&self) -> bool

true when type is Attested Computation.

Source

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.

Source

pub fn parameters(&self) -> Vec<Parameter>

The declared parameters an agent may fill.

Source

pub fn computation(&self) -> Option<Cow<'_, str>>

The computation path, when the computation lives in a file rather than a body block.

Source

pub fn executor(&self) -> Option<Executor>

The executor: how the computation is run, and what a receipt carries.

Source

pub fn attester(&self) -> Option<Attester>

The attester: deterministic code that turns a receipt into a verdict.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> Frontmatter

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 Frontmatter

Source§

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

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

impl Default for Frontmatter

Source§

fn default() -> Frontmatter

Returns the “default value” for a type. Read more
Source§

impl Display for Frontmatter

Source§

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

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

impl<'a> Extend<(&'a str, Value)> for Frontmatter

Source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = (&'a str, Value)>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Extend<(String, Value)> for Frontmatter

Source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = (String, Value)>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Extend<(Value, Value)> for Frontmatter

Source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = (Value, Value)>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<Frontmatter> for Mapping

Source§

fn from(fm: Frontmatter) -> Mapping

Converts to this type from the input type.
Source§

impl From<Mapping> for Frontmatter

Source§

fn from(map: Mapping) -> Frontmatter

Converts to this type from the input type.
Source§

impl<'a> FromIterator<(&'a str, Value)> for Frontmatter

Source§

fn from_iter<T>(iter: T) -> Frontmatter
where T: IntoIterator<Item = (&'a str, Value)>,

Creates a value from an iterator. Read more
Source§

impl FromIterator<(String, Value)> for Frontmatter

Source§

fn from_iter<T>(iter: T) -> Frontmatter
where T: IntoIterator<Item = (String, Value)>,

Creates a value from an iterator. Read more
Source§

impl FromIterator<(Value, Value)> for Frontmatter

Source§

fn from_iter<T>(iter: T) -> Frontmatter
where T: IntoIterator<Item = (Value, Value)>,

Creates a value from an iterator. Read more
Source§

impl FromStr for Frontmatter

Source§

type Err = DocumentError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Frontmatter, <Frontmatter as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Frontmatter

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Frontmatter

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> FromIn<'a, T> for T

Source§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

Source§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
Source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToDebugString for T
where T: Debug,

Source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
Source§

impl<T> ToLine for T
where T: Display,

Source§

fn to_line(&self) -> Line<'_>

Converts the value to a Line.
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> ToSpan for T
where T: Display,

Source§

fn to_span(&self) -> Span<'_>

Converts the value to a Span.
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> ToText for T
where T: Display,

Source§

fn to_text(&self) -> Text<'_>

Converts the value to a Text.
Source§

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

Source§

type Error = !

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, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U