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
impl RelayHint
sourcepub fn new(
name: Option<String>,
tcp: impl IntoIterator<Item = DirectHint>,
ws: impl IntoIterator<Item = Url>,
) -> Self
pub fn new( name: Option<String>, tcp: impl IntoIterator<Item = DirectHint>, ws: impl IntoIterator<Item = Url>, ) -> Self
Create a new relay hint
sourcepub fn from_urls(
name: Option<String>,
urls: impl IntoIterator<Item = Url>,
) -> Result<Self, RelayHintParseError>
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();sourcepub 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
pub fn can_merge(&self, other: &Self) -> bool
Whether the relay server is probably the same
sourcepub 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
pub fn merge(self, other: Self) -> Self
Extend this server with additional endpoints
sourcepub 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
pub fn merge_mut(&mut self, other: Self)
Extend this server with additional endpoints
sourcepub 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
pub fn merge_into(self, collection: &mut Vec<RelayHint>)
Deduplicate and merge the hints us into theirs
Trait Implementations§
source§impl<'de> Deserialize<'de> for RelayHint
impl<'de> Deserialize<'de> for RelayHint
source§fn deserialize<D>(de: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(de: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl Eq for RelayHint
impl StructuralPartialEq for RelayHint
Auto Trait Implementations§
impl Freeze for RelayHint
impl RefUnwindSafe for RelayHint
impl Send for RelayHint
impl Sync for RelayHint
impl Unpin for RelayHint
impl UnwindSafe for RelayHint
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)