pub enum AddrType {
Hostname = 0,
IPv4 = 4,
IPv6 = 6,
ErrorTransient = 16,
ErrorPermanent = 17,
Unknown = 18,
}Expand description
Address type identifier for relay addresses.
Indicates the format of an address in the Tor protocol. This is used in NETINFO cells and other places where addresses are exchanged.
§Variants
| Variant | Value | Description |
|---|---|---|
Hostname | 0 | DNS hostname (not typically used) |
IPv4 | 4 | IPv4 address (4 bytes) |
IPv6 | 6 | IPv6 address (16 bytes) |
ErrorTransient | 16 | Temporary error retrieving address |
ErrorPermanent | 17 | Permanent error retrieving address |
Unknown | - | Unrecognized address type |
§Example
use stem_rs::client::datatype::AddrType;
let (addr_type, raw_value) = AddrType::get(4);
assert_eq!(addr_type, AddrType::IPv4);
assert_eq!(raw_value, 4);
// Unknown types preserve the raw value
let (addr_type, raw_value) = AddrType::get(99);
assert_eq!(addr_type, AddrType::Unknown);
assert_eq!(raw_value, 99);Variants§
Hostname = 0
DNS hostname.
IPv4 = 4
IPv4 address (4 bytes).
IPv6 = 6
IPv6 address (16 bytes).
ErrorTransient = 16
Temporary error retrieving the address.
ErrorPermanent = 17
Permanent error retrieving the address.
Unknown = 18
Unrecognized address type.
Implementations§
Source§impl AddrType
impl AddrType
Sourcepub fn get(val: u8) -> (AddrType, u8)
pub fn get(val: u8) -> (AddrType, u8)
Converts a raw byte value to an AddrType and its integer representation.
§Arguments
val- The raw address type byte from the protocol
§Returns
A tuple of (AddrType, u8) where the second element is the original
byte value. This preserves unknown type values for round-tripping.
§Example
use stem_rs::client::datatype::AddrType;
assert_eq!(AddrType::get(4), (AddrType::IPv4, 4));
assert_eq!(AddrType::get(6), (AddrType::IPv6, 6));
assert_eq!(AddrType::get(99), (AddrType::Unknown, 99));Trait Implementations§
impl Copy for AddrType
impl Eq for AddrType
impl StructuralPartialEq for AddrType
Auto Trait Implementations§
impl Freeze for AddrType
impl RefUnwindSafe for AddrType
impl Send for AddrType
impl Sync for AddrType
impl Unpin for AddrType
impl UnwindSafe for AddrType
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