pub enum PeerLookup {
Confirmed(PeerLocation),
Unconfirmed {
location: PeerLocation,
why: Unconfirmed,
},
Mismatched {
location: PeerLocation,
declares: String,
},
Unknown,
}Expand description
What a host knows about where one workspace is — and how sure it is.
Note what is not here: an error case. A peer that cannot be found, cannot be read, or turns out to be someone else is never a failure, because a foreign reference is carried whether or not it resolves. Every variant is an answer.
Variants§
Confirmed(PeerLocation)
A location, and the workspace there declares the name that was asked
for. The only variant followable returns.
Unconfirmed
A location whose occupant could not be checked against the name. Usable
on the reader’s say-so (followable_unverified), not on prov’s.
Fields
location: PeerLocationWhere the host says the workspace is.
why: UnconfirmedWhy the claim could not be checked.
Mismatched
A location occupied by a workspace that calls itself something else.
This is the failure the design exists to prevent, caught: the map says
notes is here, the workspace here says it is journal, and following
that would land every id:notes/… reference on real documents in the
wrong archive. Never followable, by either accessor, at any insistence —
there is no reader preference that makes a known-wrong answer right.
Fields
location: PeerLocationWhere the host says the workspace is.
Unknown
No location on record. The ordinary state — most workspaces have never heard of most other workspaces.
Implementations§
Source§impl PeerLookup
impl PeerLookup
Sourcepub fn confirm(asked: &str, location: PeerLocation, declares: &str) -> Self
pub fn confirm(asked: &str, location: PeerLocation, declares: &str) -> Self
Weigh a location against what the workspace there calls itself. This
is the verification, and a resolver that has read the peer’s config
should reach Confirmed only through here.
declares is the peer’s own
workspace_id, empty when it
is anonymous — the same convention that field already uses, so a host can
pass it straight through without deciding what an empty name means.
Placing the comparison in a constructor is the point. A host that made
this judgment itself would be free to accept a near-miss, or to skip the
check on a fast path and still say Confirmed; here the only way to
claim confirmation is to have the evidence in hand at the call.
Sourcepub fn unreadable(location: PeerLocation) -> Self
pub fn unreadable(location: PeerLocation) -> Self
A location whose workspace could not be opened at all.
Sourcepub fn unchecked(location: PeerLocation) -> Self
pub fn unchecked(location: PeerLocation) -> Self
A location the resolver did not check — a URL, typically.
Sourcepub fn followable(&self) -> Option<&PeerLocation>
pub fn followable(&self) -> Option<&PeerLocation>
The location to follow, or None. Some only when the workspace there
answered to the name asked for.
This is the strict accessor and the default one. A caller that reaches for it cannot resolve into the wrong archive, because the archive confirmed it is the right one.
Sourcepub fn followable_unverified(&self) -> Option<&PeerLocation>
pub fn followable_unverified(&self) -> Option<&PeerLocation>
The location to follow when the reader has accepted an unconfirmed one — an anonymous peer, or a URL nothing local can check.
Still None for Mismatched. The escape is
for absent evidence, never for evidence pointing the other way.
Sourcepub fn location(&self) -> Option<&PeerLocation>
pub fn location(&self) -> Option<&PeerLocation>
Every location on record, followable or not — for saying why a reference did not resolve. A diagnostic must be able to name the mismatched directory; that is the whole content of the complaint.
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Whether the host has no location on record at all.
Trait Implementations§
Source§impl Clone for PeerLookup
impl Clone for PeerLookup
Source§fn clone(&self) -> PeerLookup
fn clone(&self) -> PeerLookup
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 PeerLookup
impl Debug for PeerLookup
impl Eq for PeerLookup
Source§impl PartialEq for PeerLookup
impl PartialEq for PeerLookup
impl StructuralPartialEq for PeerLookup
Auto Trait Implementations§
impl Freeze for PeerLookup
impl RefUnwindSafe for PeerLookup
impl Send for PeerLookup
impl Sync for PeerLookup
impl Unpin for PeerLookup
impl UnsafeUnpin for PeerLookup
impl UnwindSafe for PeerLookup
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.