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 portIPv6: IPv6 address and portFingerprint: 40-character hex relay fingerprintEd25519: Base64-encoded Ed25519 public keyUnknown: 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).
IPv6
IPv6 address and port (type 1).
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.
Implementations§
Source§impl LinkSpecifier
impl LinkSpecifier
Sourcepub fn pack(&self) -> Vec<u8> ⓘ
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 portTrait Implementations§
Source§impl Clone for LinkSpecifier
impl Clone for LinkSpecifier
Source§fn clone(&self) -> LinkSpecifier
fn clone(&self) -> LinkSpecifier
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LinkSpecifier
impl Debug for LinkSpecifier
Source§impl PartialEq for LinkSpecifier
impl PartialEq for LinkSpecifier
impl StructuralPartialEq for LinkSpecifier
Auto Trait Implementations§
impl Freeze for LinkSpecifier
impl RefUnwindSafe for LinkSpecifier
impl Send for LinkSpecifier
impl Sync for LinkSpecifier
impl Unpin for LinkSpecifier
impl UnwindSafe for LinkSpecifier
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
Mutably borrows from an owned value. Read more