Skip to main content

Destination

Enum Destination 

Source
pub enum Destination {
    Document {
        path: PathBuf,
        exists: bool,
    },
    SameDocument,
    External(String),
    Foreign {
        workspace: String,
        id: String,
    },
    UnresolvedId(String),
    AmbiguousAlias(String),
    Unresolvable {
        target: String,
        why: String,
    },
}
Expand description

Where a link lands.

prov’s own Target is the resolution; this adds the two things a frontend about to open a file needs and Target deliberately does not carry — an absolute path rather than a workspace-relative one, and whether the file is there.

Variants§

§

Document

A document in this workspace, at an absolute path.

exists is false for a broken link. It is still a Document and not an error case: the target is well-formed and names a place in this workspace, and an editor’s right answer to a broken link is usually to say so and offer to create it, not to refuse to describe it.

Fields

§path: PathBuf

Absolute, ready to open.

§exists: bool

Whether a file is actually there.

§

SameDocument

A #locator alone — a place inside the document the link is written in. prov does not read a document’s internal address space, so where that place is, is the frontend’s question to answer.

§

External(String)

A URL or mail address. Off-workspace by construction: prov recognizes it by syntax and never resolves it.

§

Foreign

id:<workspace>/<id> — a document named in another workspace. prov holds no map from a workspace name to a location (that map is a property of the device, not of the archive), so this is as far as resolution goes.

Fields

§workspace: String

The workspace qualifier, as written.

§id: String

The id within it, as written — never check-verified, since that workspace owns its id space.

§

UnresolvedId(String)

An id: target with no live registry entry: unknown, tombstoned, or a workspace with no registry at all.

§

AmbiguousAlias(String)

A nominal ([[My File]]) target several documents claim, so it names no one of them.

§

Unresolvable

The target is well-formed but cannot be resolved from here, with the reason — a /-absolute path asked about outside any workspace, say.

Fields

§target: String

The target as written.

§why: String

Why, in a sentence a status line can show.

Implementations§

Source§

impl Destination

Source

pub fn openable(&self) -> Option<&Path>

The file to open, when there is one that exists.

Source

pub fn describe(&self) -> String

A one-line description, for a status line that has to say what happened when nothing opened.

Examples found in repository?
examples/inspect.rs (line 50)
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}

Trait Implementations§

Source§

impl Clone for Destination

Source§

fn clone(&self) -> Destination

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 Destination

Source§

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

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

impl Eq for Destination

Source§

impl PartialEq for Destination

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Destination

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.