pub struct Puncher { /* private fields */ }Expand description
NAT traversal puncher for establishing direct connections.
The Puncher handles NAT type detection and hole punching to establish
direct peer-to-peer connections.
§Examples
// Get NAT information
let nat_info = puncher.nat_info();
println!("NAT Type: {:?}", nat_info.nat_type);Implementations§
Source§impl Puncher
impl Puncher
Sourcepub async fn punch_conv(
&self,
kcp_conv: u32,
punch_info: PunchInfo,
) -> Result<()>
pub async fn punch_conv( &self, kcp_conv: u32, punch_info: PunchInfo, ) -> Result<()>
Attempts to punch through NAT with a custom KCP conversation ID.
This allows you to establish multiple independent KCP connections with different conversation IDs.
§Arguments
kcp_conv- The KCP conversation ID to usepunch_info- Information about the target peer
§Examples
let kcp_conv = 12345;
let punch_info = PunchInfo::default();
puncher.punch_conv(kcp_conv, punch_info).await?;pub fn nat_info(&self) -> NatInfo
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Puncher
impl !RefUnwindSafe for Puncher
impl Send for Puncher
impl Sync for Puncher
impl Unpin for Puncher
impl !UnwindSafe for Puncher
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