Skip to main content

SourceClass

Enum SourceClass 

Source
pub enum SourceClass {
    Operator {
        host: String,
        port: u16,
    },
    Relay {
        host: String,
    },
    Public {
        host: String,
    },
    PeerV4 {
        a: u8,
        b: u8,
    },
    PeerV6 {
        h0: u16,
        h1: u16,
    },
}
Expand description

The grammar Reading::source follows (SPEC.md §7.2). Each variant is one independence class; two readings whose classes render the SAME string are the same class and cannot corroborate each other.

Variants§

§

Operator

A server the operator configured (a DIG_STUN_SERVER entry). Each configured endpoint is its own class — the operator vouched for it specifically.

Fields

§host: String

The endpoint host, normalised the same way the operator’s config entry was.

§port: u16

The endpoint port.

§

Relay

The DIG relay’s co-located STUN server. One class per relay host.

Fields

§host: String

The relay’s host.

§

Public

A third-party public STUN host (stun.l.google.com, stun.cloudflare.com, …). One class per host — they are different operators.

Fields

§host: String

The public STUN host.

§

PeerV4

A DIG peer answering over IPv4 (SPEC.md §6). One class per IPv4 /16 — the SAME partition dig_gossip::util::ip_address::subnet_group uses, so a consumer already holding that group key renders the identical class from the same IP.

Fields

§a: u8

The first octet of the peer’s transport address.

§b: u8

The second octet of the peer’s transport address.

§

PeerV6

A DIG peer answering over IPv6. One class per IPv6 /32.

Fields

§h0: u16

The first 16-bit group of the peer’s transport address.

§h1: u16

The second 16-bit group of the peer’s transport address.

Implementations§

Source§

impl SourceClass

Source

pub fn operator(host: impl Into<String>, port: u16) -> Self

The class for a server the operator configured.

Source

pub fn relay(host: impl Into<String>) -> Self

The class for the DIG relay’s co-located STUN server.

Source

pub fn public(host: impl Into<String>) -> Self

The class for a third-party public STUN host.

Source

pub fn peer(ip: IpAddr) -> Self

The class for a DIG peer, from the peer’s TRANSPORT address ip. ip is folded per SPEC.md §5.3 (fold_ip) before its leading bytes are taken, so a mapped or compat IPv6 peer renders the same class as its plain-IPv4 twin. A consumer that already computed dig_gossip::util::ip_address::subnet_group(ip) for the same ip lands in the same partition (SPEC.md §7.2) — this crate does not, and must not, re-implement that function.

Source

pub fn parse(s: &str) -> Option<Self>

Parse a rendered class back out of the grammar. Round-trips every form the Display impl above produces; None for anything else.

Trait Implementations§

Source§

impl Clone for SourceClass

Source§

fn clone(&self) -> SourceClass

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 SourceClass

Source§

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

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

impl Display for SourceClass

Source§

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

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

impl Eq for SourceClass

Source§

impl PartialEq for SourceClass

Source§

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

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.