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.
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
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.
Implementations§
Source§impl Destination
impl Destination
Sourcepub fn describe(&self) -> String
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?
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
impl Clone for Destination
Source§fn clone(&self) -> Destination
fn clone(&self) -> Destination
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Destination
impl Debug for Destination
impl Eq for Destination
Source§impl PartialEq for Destination
impl PartialEq for Destination
impl StructuralPartialEq for Destination
Auto Trait Implementations§
impl Freeze for Destination
impl RefUnwindSafe for Destination
impl Send for Destination
impl Sync for Destination
impl Unpin for Destination
impl UnsafeUnpin for Destination
impl UnwindSafe for Destination
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.