Enum tor_linkspec::RelayId
source · [−]#[non_exhaustive]
pub enum RelayId {
Ed25519(Ed25519Identity),
Rsa(RsaIdentity),
}Expand description
A single relay identity.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Ed25519(Ed25519Identity)
An Ed25519 identity.
Rsa(RsaIdentity)
An RSA identity.
Implementations
sourceimpl RelayId
impl RelayId
sourcepub fn as_ref(&self) -> RelayIdRef<'_>
pub fn as_ref(&self) -> RelayIdRef<'_>
Return a RelayIdRef pointing to the contents of this identity.
sourcepub fn from_type_and_bytes(
id_type: RelayIdType,
id: &[u8]
) -> Result<Self, RelayIdError>
pub fn from_type_and_bytes(
id_type: RelayIdType,
id: &[u8]
) -> Result<Self, RelayIdError>
Try to construct a RelayId of a provided id_type from a byte-slice.
Return RelayIdError::BadLength if the slice is not the correct length for the key.
sourcepub fn id_type(&self) -> RelayIdType
pub fn id_type(&self) -> RelayIdType
Return the type of this relay identity.
sourcepub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &mut [u8]impl Write for &mut [u8]impl Read for &[u8]
Return a byte-slice corresponding to the contents of this identity.
The return value discards the type of the identity, and so should be handled with care to make sure that it does not get confused with an identity of some other type.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for RelayId
impl<'de> Deserialize<'de> for RelayId
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'a> From<&'a RelayId> for RelayIdRef<'a>
impl<'a> From<&'a RelayId> for RelayIdRef<'a>
sourceimpl From<Ed25519Identity> for RelayId
impl From<Ed25519Identity> for RelayId
sourcefn from(original: Ed25519Identity) -> RelayId
fn from(original: Ed25519Identity) -> RelayId
Converts to this type from the input type.
sourceimpl From<RsaIdentity> for RelayId
impl From<RsaIdentity> for RelayId
sourcefn from(original: RsaIdentity) -> RelayId
fn from(original: RsaIdentity) -> RelayId
Converts to this type from the input type.
sourceimpl FromIterator<RelayId> for RelayIdSet
impl FromIterator<RelayId> for RelayIdSet
sourcefn from_iter<T: IntoIterator<Item = RelayId>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = RelayId>>(iter: T) -> Self
Creates a value from an iterator. Read more
sourceimpl FromStr for RelayId
impl FromStr for RelayId
sourcefn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Try to parse s as a RelayId.
We use the following format, based on the one used by C tor.
- An optional
$followed by a 40 byte hex string is always an RSA key. - A 43 character un-padded base-64 string is always an Ed25519 key.
- The name of an algorithm (“rsa” or “ed25519”), followed by a colon and and an un-padded base-64 string is a key of that type.
type Err = RelayIdError
type Err = RelayIdError
The associated error which can be returned from parsing.
sourceimpl PartialEq<Ed25519Identity> for RelayId
impl PartialEq<Ed25519Identity> for RelayId
sourcefn eq(&self, other: &Ed25519Identity) -> bool
fn eq(&self, other: &Ed25519Identity) -> bool
sourceimpl PartialEq<RsaIdentity> for RelayId
impl PartialEq<RsaIdentity> for RelayId
sourcefn eq(&self, other: &RsaIdentity) -> bool
fn eq(&self, other: &RsaIdentity) -> bool
impl Copy for RelayId
impl Eq for RelayId
impl StructuralEq for RelayId
impl StructuralPartialEq for RelayId
Auto Trait Implementations
impl RefUnwindSafe for RelayId
impl Send for RelayId
impl Sync for RelayId
impl Unpin for RelayId
impl UnwindSafe for RelayId
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more