magic_wormhole::transit

Struct RelayHint

source
pub struct RelayHint {
    pub name: Option<String>,
    pub tcp: HashSet<DirectHint>,
    pub ws: HashSet<Url>,
}
Expand description

Hint describing a relay server

A server may be reachable at multiple locations. Any two must be relayable over that server, therefore a client may pick only one of these per hint.

All locations are URLs, but here they are already deconstructed and grouped by schema out of convenience.

Fields§

§name: Option<String>

Human readable name. The expectation is that when a server has multiple endpoints, the expectation is that the domain name is used as name

§tcp: HashSet<DirectHint>

TCP endpoints of that relay

§ws: HashSet<Url>

WebSockets endpoints of that relay

Implementations§

source§

impl RelayHint

source

pub fn new( name: Option<String>, tcp: impl IntoIterator<Item = DirectHint>, ws: impl IntoIterator<Item = Url>, ) -> Self

Create a new relay hint

source

pub fn from_urls( name: Option<String>, urls: impl IntoIterator<Item = Url>, ) -> Result<Self, RelayHintParseError>

Construct a relay hint from a list of multiple endpoints, and optionally a name.

Not all URLs are acceptable, therefore this method is fallible. Especially, TCP endpoints must be encoded as tcp://hostname:port. All URLs must be absolute, i.e. start with a /.

Basic usage (default server):

use magic_wormhole::transit;
let hint =
    transit::RelayHint::from_urls(None, [transit::DEFAULT_RELAY_SERVER.parse().unwrap()])
        .unwrap();

Custom relay server from url with name:

use magic_wormhole::transit;
let hint = transit::RelayHint::from_urls(url.host_str().map(str::to_owned), [url]).unwrap();
source

pub fn can_merge(&self, other: &Self) -> bool

👎Deprecated since 0.7.0: This will be a private method in the future. Open an issue if you require access to protocol intrinsics in the future

Whether the relay server is probably the same

source

pub fn merge(self, other: Self) -> Self

👎Deprecated since 0.7.0: This will be a private method in the future. Open an issue if you require access to protocol intrinsics in the future

Extend this server with additional endpoints

source

pub fn merge_mut(&mut self, other: Self)

👎Deprecated since 0.7.0: This will be a private method in the future. Open an issue if you require access to protocol intrinsics in the future

Extend this server with additional endpoints

source

pub fn merge_into(self, collection: &mut Vec<RelayHint>)

👎Deprecated since 0.7.0: This will be a private method in the future. Open an issue if you require access to protocol intrinsics in the future

Deduplicate and merge the hints us into theirs

Trait Implementations§

source§

impl Clone for RelayHint

source§

fn clone(&self) -> RelayHint

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RelayHint

source§

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

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

impl Default for RelayHint

source§

fn default() -> RelayHint

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for RelayHint

source§

fn deserialize<D>(de: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for RelayHint

source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for RelayHint

source§

fn serialize<S>(&self, ser: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for RelayHint

source§

impl StructuralPartialEq for RelayHint

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = 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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,