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