Skip to main content

Facet

Enum Facet 

Source
pub enum Facet {
    Relation(RelationFacet),
    Policy,
    Identity,
    Title,
    Payload(Payload),
    Stamp,
    Field(FieldFacet),
    Carried,
}
Expand description

What a frontmatter key is to prov.

Exhaustive over a document’s top-level keys: every key falls in exactly one of these, and Facet::Carried is the one that means “prov does not read this”. A nested key takes its top-level ancestor’s facet — see Facets::of.

Variants§

§

Relation(RelationFacet)

A link field: the targets are edges in the workspace graph.

§

Policy

The root’s prov: block — workspace policy, inline.

§

Identity

id — the document’s stable identity. Minted and maintained by the workspace, not typed.

§

Title

title — read back by prov for nominal references and for the generated about page, but written by a person.

§

Payload(Payload)

One of the four keys on the opaque-payload axis.

§

Stamp

The field the workspace’s updated: config names — machine-stamped in RFC 3339 UTC because prov reads it back to know when to rewrite it. The name is the workspace’s; a human-friendly date is a different, user-owned field prov never touches.

§

Field(FieldFacet)

Declared in fields.<name>: prov resolves its values against a vocabulary, or at least knows their type.

§

Carried

Carried by prov and never read by it. The default, and the majority of an ordinary document.

Implementations§

Source§

impl Facet

Source

pub fn read_by_prov(&self) -> bool

Whether prov reads this key at all. false only for Carried.

Source

pub fn structural(&self) -> bool

Whether this is prov’s own structure rather than something the document says about itself — the line a frontend that separates the two draws.

contents, part_of, config, prov:, id, content_hash are structure. title is not, and neither is a declared field: prov reads both, but a person wrote them, and putting audience: public behind the same fold as id hides the thing the reader came for.

A question, not a policy. Nothing in this crate acts on it.

Examples found in repository?
examples/inspect.rs (line 25)
7fn main() {
8    let path = std::path::PathBuf::from(std::env::args().nth(1).expect("a document"));
9    let view = WorkspaceView::discover(&path).expect("discovery");
10    match &view {
11        Some(v) => println!("workspace: {}", v.root_dir().display()),
12        None => println!("workspace: none"),
13    }
14    let facets = view
15        .as_ref()
16        .map(|v| v.facets().clone())
17        .unwrap_or_default();
18    let schema = view.as_ref().map(|v| v.schema_for(&path));
19    let session =
20        DocumentSession::open_managed(&path, schema, facets.managed_key_names()).expect("open");
21
22    println!("\nkeys:");
23    for (key, facet) in facets.classify(session.meta()) {
24        let flags = [
25            facet.structural().then_some("structural"),
26            facet.managed().then_some("managed"),
27        ]
28        .into_iter()
29        .flatten()
30        .collect::<Vec<_>>()
31        .join(",");
32        println!("  {key:<14} {:<9} {flags}", facet.kind());
33    }
34
35    println!("\nlinks:");
36    for link in links_in(session.meta(), &facets) {
37        let landing = match &view {
38            Some(v) => v.resolve(&path, &link),
39            None => resolve_without_workspace(&path, &link),
40        };
41        let mark = if matches!(landing, Destination::Document { exists: true, .. }) {
42            "→"
43        } else {
44            "·"
45        };
46        println!(
47            "  {mark} {:<10} {:<22} {}",
48            link.relation.name,
49            link.display(),
50            landing.describe()
51        );
52    }
53}
Source

pub fn managed(&self) -> bool

Whether the workspace maintains this value, so an editor should draw the row and decline the edit rather than offer a text box.

id is minted, content_hash is computed, the updated stamp is written on save. Typing into any of the three does not change what it will say after the next prov operation; it only makes the document briefly wrong. This is exactly flower’s derived set — see managed_keys.

Examples found in repository?
examples/inspect.rs (line 26)
7fn main() {
8    let path = std::path::PathBuf::from(std::env::args().nth(1).expect("a document"));
9    let view = WorkspaceView::discover(&path).expect("discovery");
10    match &view {
11        Some(v) => println!("workspace: {}", v.root_dir().display()),
12        None => println!("workspace: none"),
13    }
14    let facets = view
15        .as_ref()
16        .map(|v| v.facets().clone())
17        .unwrap_or_default();
18    let schema = view.as_ref().map(|v| v.schema_for(&path));
19    let session =
20        DocumentSession::open_managed(&path, schema, facets.managed_key_names()).expect("open");
21
22    println!("\nkeys:");
23    for (key, facet) in facets.classify(session.meta()) {
24        let flags = [
25            facet.structural().then_some("structural"),
26            facet.managed().then_some("managed"),
27        ]
28        .into_iter()
29        .flatten()
30        .collect::<Vec<_>>()
31        .join(",");
32        println!("  {key:<14} {:<9} {flags}", facet.kind());
33    }
34
35    println!("\nlinks:");
36    for link in links_in(session.meta(), &facets) {
37        let landing = match &view {
38            Some(v) => v.resolve(&path, &link),
39            None => resolve_without_workspace(&path, &link),
40        };
41        let mark = if matches!(landing, Destination::Document { exists: true, .. }) {
42            "→"
43        } else {
44            "·"
45        };
46        println!(
47            "  {mark} {:<10} {:<22} {}",
48            link.relation.name,
49            link.display(),
50            landing.describe()
51        );
52    }
53}
Source

pub fn relation(&self) -> Option<&RelationFacet>

The relation this key declares, when it is one — the test a frontend applies before offering to follow a row.

Source

pub fn kind(&self) -> &'static str

A short, frontend-neutral name for the kind — for a badge, a filter, or a status line that wants to say what a row is without a match arm.

Examples found in repository?
examples/inspect.rs (line 32)
7fn main() {
8    let path = std::path::PathBuf::from(std::env::args().nth(1).expect("a document"));
9    let view = WorkspaceView::discover(&path).expect("discovery");
10    match &view {
11        Some(v) => println!("workspace: {}", v.root_dir().display()),
12        None => println!("workspace: none"),
13    }
14    let facets = view
15        .as_ref()
16        .map(|v| v.facets().clone())
17        .unwrap_or_default();
18    let schema = view.as_ref().map(|v| v.schema_for(&path));
19    let session =
20        DocumentSession::open_managed(&path, schema, facets.managed_key_names()).expect("open");
21
22    println!("\nkeys:");
23    for (key, facet) in facets.classify(session.meta()) {
24        let flags = [
25            facet.structural().then_some("structural"),
26            facet.managed().then_some("managed"),
27        ]
28        .into_iter()
29        .flatten()
30        .collect::<Vec<_>>()
31        .join(",");
32        println!("  {key:<14} {:<9} {flags}", facet.kind());
33    }
34
35    println!("\nlinks:");
36    for link in links_in(session.meta(), &facets) {
37        let landing = match &view {
38            Some(v) => v.resolve(&path, &link),
39            None => resolve_without_workspace(&path, &link),
40        };
41        let mark = if matches!(landing, Destination::Document { exists: true, .. }) {
42            "→"
43        } else {
44            "·"
45        };
46        println!(
47            "  {mark} {:<10} {:<22} {}",
48            link.relation.name,
49            link.display(),
50            landing.describe()
51        );
52    }
53}

Trait Implementations§

Source§

impl Clone for Facet

Source§

fn clone(&self) -> Facet

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 Facet

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Facet

§

impl RefUnwindSafe for Facet

§

impl Send for Facet

§

impl Sync for Facet

§

impl Unpin for Facet

§

impl UnsafeUnpin for Facet

§

impl UnwindSafe for Facet

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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, !>

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.