Skip to main content

BodyLink

Struct BodyLink 

Source
pub struct BodyLink {
    pub kind: BodyLinkKind,
    pub raw: String,
    pub target: String,
    pub heading: Option<String>,
    pub block: Option<String>,
    pub alias: Option<String>,
    pub size: Option<Size>,
    pub byte_start: usize,
    pub byte_end: usize,
}
Expand description

One outgoing reference found in a body, with its span, before resolution.

Separate from a resolved link because extraction and resolution have different lifetimes: a note’s links change when the note is edited, and what they resolve to changes when any other note in the vault is created or renamed. A caller that caches the first and recomputes the second needs them to be two types.

Fields§

§kind: BodyLinkKind

Which syntax produced the link.

§raw: String

The reference as written between the delimiters, with any code inside it blanked to spaces.

§target: String

What resolution runs against. A wikilink’s raw minus #heading / ^block / |alias and the \ escaping the pipe; a markdown link’s URL percent-decoded and minus a trailing .md. Empty for a link to the note it is written in (see ScanOptions::self_links).

§heading: Option<String>

A wikilink’s #heading, as crate::WikiLink::heading. None for a markdown link.

§block: Option<String>

A wikilink’s #^block, as crate::WikiLink::block. None for a markdown link.

§alias: Option<String>

A wikilink’s or embed’s |alias: the text after the first | outside code, read from the body so code inside it is kept. None when there is none or it is empty, and for a markdown link.

§size: Option<Size>

An embed’s size, |300 or |300x200, as crate::WikiLink::size.

§byte_start: usize

Byte offset within the body where the whole link syntax starts. An embed’s leading ! is inside it.

§byte_end: usize

Byte offset within the body just past the end of the link syntax.

Trait Implementations§

Source§

fn clone(&self) -> Self

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§

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

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

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

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

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

Inequality operator !=. 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 = !

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.