LinkSpecifier

Enum LinkSpecifier 

Source
pub enum LinkSpecifier {
    IPv4 {
        address: String,
        port: u16,
    },
    IPv6 {
        address: String,
        port: u16,
    },
    Fingerprint(String),
    Ed25519(String),
    Unknown {
        link_type: u8,
        data: Vec<u8>,
    },
}
Expand description

Link specifier for v3 introduction points.

Link specifiers describe how to connect to an introduction point relay. They can specify IPv4/IPv6 addresses, relay fingerprints, or Ed25519 identity keys.

§Variants

  • IPv4: IPv4 address and port
  • IPv6: IPv6 address and port
  • Fingerprint: 40-character hex relay fingerprint
  • Ed25519: Base64-encoded Ed25519 public key
  • Unknown: Unrecognized link specifier type

§Wire Format

Link specifiers are encoded as:

  • 1 byte: type
  • 1 byte: length
  • N bytes: data (format depends on type)

§Example

use stem_rs::descriptor::hidden::LinkSpecifier;

let ipv4 = LinkSpecifier::IPv4 {
    address: "192.168.1.1".to_string(),
    port: 9001,
};

let packed = ipv4.pack();
assert_eq!(packed[0], 0); // Type 0 = IPv4
assert_eq!(packed[1], 6); // Length = 6 bytes (4 addr + 2 port)

Variants§

§

IPv4

IPv4 address and port (type 0).

Fields

§address: String

Dotted-decimal IPv4 address.

§port: u16

TCP port number.

§

IPv6

IPv6 address and port (type 1).

Fields

§address: String

Colon-separated IPv6 address.

§port: u16

TCP port number.

§

Fingerprint(String)

Relay fingerprint (type 2).

40-character uppercase hex string representing the relay’s SHA-1 identity hash.

§

Ed25519(String)

Ed25519 identity key (type 3).

Base64-encoded 32-byte Ed25519 public key.

§

Unknown

Unknown or unrecognized link specifier type.

Fields

§link_type: u8

The type byte from the wire format.

§data: Vec<u8>

Raw data bytes.

Implementations§

Source§

impl LinkSpecifier

Source

pub fn pack(&self) -> Vec<u8>

Packs this link specifier into its wire format.

The wire format is:

  • 1 byte: type (0=IPv4, 1=IPv6, 2=fingerprint, 3=Ed25519)
  • 1 byte: length of data
  • N bytes: type-specific data
§Returns

A byte vector containing the packed link specifier.

§Example
use stem_rs::descriptor::hidden::LinkSpecifier;

let spec = LinkSpecifier::IPv4 {
    address: "1.2.3.4".to_string(),
    port: 9001,
};
let packed = spec.pack();
assert_eq!(packed.len(), 8); // 1 type + 1 len + 4 addr + 2 port

Trait Implementations§

Source§

impl Clone for LinkSpecifier

Source§

fn clone(&self) -> LinkSpecifier

Returns a duplicate 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 LinkSpecifier

Source§

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

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

impl PartialEq for LinkSpecifier

Source§

fn eq(&self, other: &LinkSpecifier) -> 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 StructuralPartialEq for LinkSpecifier

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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.