Skip to main content

Link

Struct Link 

Source
pub struct Link {
    pub text: String,
    pub target: String,
    pub kind: LinkKind,
}
Expand description

A markdown link found in a concept body.

Fields§

§text: String

The link text (between [ and ]).

§target: String

The raw destination (between ( and )), with any title removed.

§kind: LinkKind

The classification of Link::target.

Implementations§

Source

pub fn classify(target: &str) -> LinkKind

Classifies a raw target string.

Source

pub fn resolve(&self, source: &ConceptId) -> Option<ConceptId>

Resolves an internal link to the concept id it points at, given the id of the concept the link appears in.

Returns None for external links, anchors, links to directories (targets ending in /), or targets that cannot form a valid concept id. The result is not guaranteed to exist in the bundle: broken links are permitted by the spec.

Where a target is percent-encoded this returns the literal reading; use Link::resolve_all to also consider the decoded one.

Source

pub fn resolve_all(&self, source: &ConceptId) -> Vec<ConceptId>

Every concept id this link may denote, most likely first.

A markdown destination is a URL, so a concept whose filename contains a space is normally linked as /tables/my%20notes.md. Decoding is offered as a second candidate rather than applied outright, so that a file genuinely named my%20notes.md still resolves by its literal spelling. Callers should prefer the first candidate that exists in the bundle.

Source

pub fn target_without_anchor(&self) -> &str

Returns the target with any anchor fragment removed.

Source

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

Returns the anchor fragment, if one was present.

Trait Implementations§

Source§

fn clone(&self) -> Link

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: &Link) -> 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 = 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.