pub struct HolepunchMessage {
pub msg_type: HolepunchMsgType,
pub addr: SocketAddr,
pub error_code: u32,
}Expand description
A parsed BEP 55 holepunch extension message.
Fields§
§msg_type: HolepunchMsgTypeMessage type.
addr: SocketAddrTarget/subject peer address.
error_code: u32Error code (meaningful only when msg_type == Error).
Implementations§
Source§impl HolepunchMessage
impl HolepunchMessage
Sourcepub fn rendezvous(target: SocketAddr) -> Self
pub fn rendezvous(target: SocketAddr) -> Self
Create a Rendezvous message requesting the relay connect us to target.
Sourcepub fn connect(addr: SocketAddr) -> Self
pub fn connect(addr: SocketAddr) -> Self
Create a Connect message telling a peer to initiate a connection to addr.
Sourcepub fn error(addr: SocketAddr, error: HolepunchError) -> Self
pub fn error(addr: SocketAddr, error: HolepunchError) -> Self
Create an Error message for a failed rendezvous.
Sourcepub fn to_bytes(&self) -> Bytes
pub fn to_bytes(&self) -> Bytes
Serialize to binary payload (without the BEP 10 extension header).
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Parse from binary payload (after BEP 10 extension header is stripped).
§Errors
Returns an error if the data is too short or contains invalid fields.
Trait Implementations§
Source§impl Clone for HolepunchMessage
impl Clone for HolepunchMessage
Source§fn clone(&self) -> HolepunchMessage
fn clone(&self) -> HolepunchMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 HolepunchMessage
impl Debug for HolepunchMessage
Source§impl PartialEq for HolepunchMessage
impl PartialEq for HolepunchMessage
Source§fn eq(&self, other: &HolepunchMessage) -> bool
fn eq(&self, other: &HolepunchMessage) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for HolepunchMessage
impl StructuralPartialEq for HolepunchMessage
Auto Trait Implementations§
impl Freeze for HolepunchMessage
impl RefUnwindSafe for HolepunchMessage
impl Send for HolepunchMessage
impl Sync for HolepunchMessage
impl Unpin for HolepunchMessage
impl UnsafeUnpin for HolepunchMessage
impl UnwindSafe for HolepunchMessage
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