Skip to main content

Relation

Struct Relation 

Source
pub struct Relation {
    pub name: String,
    pub inverse: Option<String>,
    pub cardinality: Cardinality,
    pub style: Option<ReferenceStyle>,
}
Expand description

A single named relation: the frontmatter key it reads, its inverse (if the pair is maintained bidirectionally), and its cardinality.

Fields§

§name: String

The frontmatter key this relation reads (e.g. "contents").

§inverse: Option<String>

The inverse relation’s name, if any (e.g. contentspart_of).

§cardinality: Cardinality

How many targets the field may hold.

§style: Option<ReferenceStyle>

The reference style prov authors this relation’s links in, overriding the workspace default. None inherits the default. This is what lets links going “down” (contents) differ from links going “up” (part_of) — style is resolved per relation (see docs/reference-styles.md).

Implementations§

Source§

impl Relation

Source

pub fn one(name: impl Into<String>) -> Self

A single-valued relation (cardinality Cardinality::One).

Source

pub fn many(name: impl Into<String>) -> Self

A multi-valued relation (cardinality Cardinality::Many).

Source

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

Declare this relation’s inverse (builder-style).

Source

pub fn style(self, style: ReferenceStyle) -> Self

Author this relation’s links in a specific reference style, overriding the workspace default (builder-style). E.g. alias wikilinks going down through contents, durable id links going up through part_of.

Trait Implementations§

Source§

impl Clone for Relation

Source§

fn clone(&self) -> Relation

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 Relation

Source§

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

Formats the value using the given formatter. 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> 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 = Infallible

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.