Skip to main content

RelationSet

Struct RelationSet 

Source
pub struct RelationSet { /* private fields */ }
Expand description

The configured set of relations for a workspace, and which one is spanning.

The spanning relation is the single-parent containment tree that gives the workspace its self-describing discovery spine. All other relations may be many-to-many overlays.

Implementations§

Source§

impl RelationSet

Source

pub fn new() -> Self

An empty relation set.

Source

pub fn with(self, relation: Relation) -> Self

Add a relation (builder-style).

Source

pub fn without(self, name: &str) -> Self

Drop the named relation, if present (builder-style) — after this, the field is not a link here, so edges ignores a document key by that name and the value reads as ordinary carried content.

The counterpart to with, and what makes a preset an overlay base rather than an all-or-nothing choice: a config that starts from diaryx and declares one relation needs a way to both redefine a name (remove, then add) and retract one, without restating the vocabulary it was otherwise happy with. See WorkspaceConfig::relation_set.

The pointer marks are deliberately untouched: dropping registry stops it being a relation but leaves registry_relation() answering, because that pointer is how a reader finds the workspace’s machinery at all (§6) and is not the vocabulary’s to revoke.

Source

pub fn spanning(self, name: impl Into<String>) -> Self

Mark the named relation as the spanning (canonical tree) relation.

Source

pub fn registry(self, name: impl Into<String>) -> Self

Mark the named relation as the registry pointer: the root document links its ID registry through this relation, which is what makes the registry reachable — workspace-critical state discovered by following links from the root, like everything else, rather than hidden in an app-private sidecar folder.

Source

pub fn config(self, name: impl Into<String>) -> Self

Mark the named relation as the config pointer: the root document links its workspace-config document through this relation — the same reachability move as the registry (§6), so workspace policy (link_format, defaults, …) is a self-describing node discovered by following links from the root, never an app-private sidecar. The config document is optional and lazily created; its absence means all defaults.

Source

pub fn deletions(self, name: impl Into<String>) -> Self

Mark the named relation as the deletion-log pointer: the root document links its deletion log through this relation — the same reachability move as the registry and config (§6). A delete destroys the bytes and records what it destroyed: where the document sat, what it was called, which id it held, and which parent listed it. That record is what restore repairs the graph from once the bytes are back. Making the log reachable is what keeps it honest: check validates it like any other member, and nothing about a deletion is hidden in an app-private folder.

Source

pub fn recycle(self, name: impl Into<String>) -> Self

Mark the named relation as the legacy recycle-bin pointer — the spelling deletions replaced.

Kept only so a root written before the rename still resolves: the log is read through this pointer when the document declares no deletions, and check reports the old spelling as a rename to make. Nothing writes it. A workspace that parked bytes under this pointer’s items/ keeps them parked out of every walk for as long as it declares it.

Source

pub fn history(self, name: impl Into<String>) -> Self

Mark the named relation as the history pointer: the root document links its history-store index through this relation — the same reachability move as the registry, config and deletion log (§6). The store holds one immutable event document per capture plus a content-addressed blob store, so a bad sync merge can be rolled back file by file. Making it reachable is what lets check validate it like any other member, and what keeps prov’s own safety net out of an app-private folder.

Source

pub fn about(self, name: impl Into<String>) -> Self

Mark the named relation as the about pointer: the root document links its generated about.md through this relation — structurally the same one-way move as the registry, config, deletion log and history (§6), but a distinct target kind (spec §4, generated prose), because the file is entirely prose in the workspace’s content format rather than a whole-file record store.

The pointer exists so prov can find the page to regenerate and validate it, and so the file is reachable rather than loose in the tree. It is deliberately not the human reader’s way in: a person opening the directory finds about.md by its name, needing no pointer, no parser and no convention beyond being able to read a text file. That is the whole point of the artifact, and why the default filename is load-bearing.

Source

pub fn diaryx() -> Self

The diaryx vocabulary: contents/part_of containment (spanning), links/link_of arbitrary cross-references, registry (the root’s pointer to its ID registry document), config (the root’s pointer to its workspace-config document), deletions (the root’s pointer to its deletion log), history (the root’s pointer to its history store), and about (the root’s pointer to its generated about.md).

recycle_bin is here too, and is not one of those. It is the spelling deletions replaced, kept readable so a root written before the rename still resolves — see recycle.

Source

pub fn diaryx_means(name: &str) -> Option<&'static str>

prov’s own human gloss for a diaryx content relation — what the preset would have written in a means: had the workspace bothered to declare it. None for any other name.

The preset is the base every workspace’s vocabulary overlays, so an undeclared contents is prov’s contents and its meaning is known here rather than being a blank a reader has to guess at. Only the four content relations are glossed: the five pointers are machinery a consumer describes in its own words (see prov’s about page), not vocabulary a reader follows.

Source

pub fn relations(&self) -> &[Relation]

The configured relations.

Source

pub fn style_for(&self, name: &str) -> Option<ReferenceStyle>

The per-relation reference style override for name, if that relation is configured and carries one. None means “inherit the workspace default” — the caller falls back to its own default style.

Source

pub fn with_styles(self, styles: &BTreeMap<String, ReferenceStyle>) -> Self

Overlay per-relation reference styles by name (builder-style) — the config-driven form of Relation::style. Each configured relation whose name appears in styles adopts that style; relations absent from the map keep whatever style they already carry (usually none → the workspace default). Names in styles with no matching relation are ignored. This is how a workspace’s vocabulary picks up the relations block of its config document (see prov’s WorkspaceConfig::resolved_relation_styles).

prov’s WorkspaceConfig::resolved_relation_styles: prov’s WorkspaceConfig::resolved_relation_styles

Source

pub fn spanning_relation(&self) -> Option<&str>

The name of the spanning relation, if one is configured.

Source

pub fn registry_relation(&self) -> Option<&str>

The name of the registry-pointer relation, if one is configured.

Source

pub fn config_relation(&self) -> Option<&str>

The name of the config-pointer relation, if one is configured.

Source

pub fn deletions_relation(&self) -> Option<&str>

The name of the deletion-log-pointer relation, if one is configured.

Source

pub fn recycle_relation(&self) -> Option<&str>

The name of the legacy recycle-bin-pointer relation, if one is configured — the spelling deletions_relation replaced, resolved only when a root declares no deletions pointer.

Source

pub fn history_relation(&self) -> Option<&str>

The name of the history-pointer relation, if one is configured.

Source

pub fn about_relation(&self) -> Option<&str>

The name of the about-pointer relation, if one is configured.

Source

pub fn edges(&self, meta: &Value) -> Vec<Edge>

Extract every link declared by a document’s metadata, tagged by relation.

Source

pub fn children(&self, meta: &Value) -> Vec<String>

The raw targets of the spanning relation — i.e. this node’s children in the canonical tree. Empty if no spanning relation is configured or the field is absent.

Trait Implementations§

Source§

impl Clone for RelationSet

Source§

fn clone(&self) -> RelationSet

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 RelationSet

Source§

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

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

impl Default for RelationSet

Source§

fn default() -> RelationSet

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

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<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.