Trait tor_linkspec::HasRelayIds

source ·
pub trait HasRelayIds {
    // Required method
    fn identity(&self, key_type: RelayIdType) -> Option<RelayIdRef<'_>>;

    // Provided methods
    fn identities(&self) -> RelayIdIter<'_, Self> { ... }
    fn ed_identity(&self) -> Option<&Ed25519Identity> { ... }
    fn rsa_identity(&self) -> Option<&RsaIdentity> { ... }
    fn has_identity(&self, id: RelayIdRef<'_>) -> bool { ... }
    fn has_any_identity(&self) -> bool { ... }
    fn same_relay_ids<T: HasRelayIds + ?Sized>(&self, other: &T) -> bool { ... }
    fn has_all_relay_ids_from<T: HasRelayIds + ?Sized>(&self, other: &T) -> bool { ... }
    fn has_any_relay_id_from<T: HasRelayIds + ?Sized>(&self, other: &T) -> bool { ... }
    fn cmp_by_relay_ids<T: HasRelayIds + ?Sized>(&self, other: &T) -> Ordering { ... }
    fn display_relay_ids(&self) -> DisplayRelayIds<'_, Self> { ... }
}
Expand description

An object containing information about a relay’s identity keys.

This trait has a fairly large number of methods, most of which you’re not actually expected to implement. The only one that you need to provide is identity.

Required Methods§

source

fn identity(&self, key_type: RelayIdType) -> Option<RelayIdRef<'_>>

Return the identity of this relay whose type is key_type, or None if the relay has no such identity.

(Currently all relays have all recognized identity types, but we might implement or deprecate an identity type in the future.)

Provided Methods§

source

fn identities(&self) -> RelayIdIter<'_, Self>

Return an iterator over all of the identities held by this object.

source

fn ed_identity(&self) -> Option<&Ed25519Identity>

Return the ed25519 identity for this relay if it has one.

source

fn rsa_identity(&self) -> Option<&RsaIdentity>

Return the RSA identity for this relay if it has one.

source

fn has_identity(&self, id: RelayIdRef<'_>) -> bool

Check whether the provided Id is a known identity of this relay.

Remember that a given set of identity keys may be incomplete: some objects that represent a relay have only a subset of the relay’s identities. Therefore, a “true” answer means that the relay has this identity, but a “false” answer could mean that the relay has a different identity of this type, or that it has no known identity of this type.

source

fn has_any_identity(&self) -> bool

Return true if this object has any known identity.

source

fn same_relay_ids<T: HasRelayIds + ?Sized>(&self, other: &T) -> bool

Return true if this object has exactly the same relay IDs as other.

source

fn has_all_relay_ids_from<T: HasRelayIds + ?Sized>(&self, other: &T) -> bool

Return true if this object has every relay ID that other does.

(It still returns true if there are some IDs in this object that are not present in other.)

source

fn has_any_relay_id_from<T: HasRelayIds + ?Sized>(&self, other: &T) -> bool

Return true if this object has any relay ID that other has.

This is symmetrical: it returns true if the two objects have any overlap in their identities.

source

fn cmp_by_relay_ids<T: HasRelayIds + ?Sized>(&self, other: &T) -> Ordering

Compare this object to another HasRelayIds.

Objects are sorted by Ed25519 identities, with ties decided by RSA identities. An absent identity of a given type is sorted before a present identity of that type.

If additional identities are added in the future, they may taken into consideration before or after the current identity types.

source

fn display_relay_ids(&self) -> DisplayRelayIds<'_, Self>

Return a reference to this object suitable for formatting its HasRelayIds members.

Object Safety§

This trait is not object safe.

Implementors§