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
impl Facet
Sourcepub fn read_by_prov(&self) -> bool
pub fn read_by_prov(&self) -> bool
Whether prov reads this key at all. false only for
Carried.
Sourcepub fn structural(&self) -> bool
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?
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}Sourcepub fn managed(&self) -> bool
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?
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}Sourcepub fn relation(&self) -> Option<&RelationFacet>
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.
Sourcepub fn kind(&self) -> &'static str
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?
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}