Skip to main content

PeerLookup

Enum PeerLookup 

Source
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: PeerLocation

Where the host says the workspace is.

§why: Unconfirmed

Why 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: PeerLocation

Where the host says the workspace is.

§declares: String

The name the workspace found there actually declares.

§

Unknown

No location on record. The ordinary state — most workspaces have never heard of most other workspaces.

Implementations§

Source§

impl PeerLookup

Source

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.

Source

pub fn unreadable(location: PeerLocation) -> Self

A location whose workspace could not be opened at all.

Source

pub fn unchecked(location: PeerLocation) -> Self

A location the resolver did not check — a URL, typically.

Source

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.

Source

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.

Source

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.

Source

pub fn is_unknown(&self) -> bool

Whether the host has no location on record at all.

Trait Implementations§

Source§

impl Clone for PeerLookup

Source§

fn clone(&self) -> PeerLookup

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 PeerLookup

Source§

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

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

impl Eq for PeerLookup

Source§

impl PartialEq for PeerLookup

Source§

fn eq(&self, other: &PeerLookup) -> 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 PeerLookup

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> 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.