pub struct CustomAddr { /* private fields */ }key only.Expand description
A custom address.
This is a generic address type with a type id and opaque data, to allow external crates to implement custom transports.
Custom addresses can be written by anybody, so you need to be prepared to handle unexpected type ids and data when parsing custom addresses.
Implementations§
Source§impl CustomAddr
impl CustomAddr
Sourcepub fn from_parts(id: u64, data: &[u8]) -> Self
pub fn from_parts(id: u64, data: &[u8]) -> Self
Creates a new CustomAddr from its parts.
Sourcepub fn id(&self) -> u64
pub fn id(&self) -> u64
Returns the transport id.
You can freely choose this. There is a table of reserved custom transport ids in https://github.com/n0-computer/iroh/blob/main/TRANSPORTS.md, where you could submit your transport for registration to get a reserved id.
But this is only relevant if you care for interop.
Sourcepub fn data(&self) -> &[u8] ⓘ
pub fn data(&self) -> &[u8] ⓘ
Returns the opaque address data for this transport.
Below a certain size (currently 30 bytes) this is stored inline, otherwise on the heap.
Note that there are no guarantees about the size of this data. When parsing custom addresses you must be prepared to handle unexpected sizes here.
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, &'static str>
pub fn from_bytes(data: &[u8]) -> Result<Self, &'static str>
Parse from bytes
Trait Implementations§
Source§impl Clone for CustomAddr
impl Clone for CustomAddr
Source§fn clone(&self) -> CustomAddr
fn clone(&self) -> CustomAddr
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more