pub struct UtpPeerConnection { /* private fields */ }Expand description
uTP peer connection wrapper
Wraps a uTP stream for BitTorrent peer communication. Provides the same interface as TCP connections but uses UDP-based uTP protocol.
Implementations§
Source§impl UtpPeerConnection
impl UtpPeerConnection
Sourcepub fn new(
socket: Arc<Mutex<UtpSocket>>,
conn_id: u16,
info_hash: [u8; 20],
) -> Self
pub fn new( socket: Arc<Mutex<UtpSocket>>, conn_id: u16, info_hash: [u8; 20], ) -> Self
Create a new uTP peer connection
Sourcepub async fn connect(addr: SocketAddr, info_hash: &[u8; 20]) -> Result<Self>
pub async fn connect(addr: SocketAddr, info_hash: &[u8; 20]) -> Result<Self>
Connect to a remote peer via uTP
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if connection is established
Sourcepub async fn perform_handshake(&mut self) -> Result<()>
pub async fn perform_handshake(&mut self) -> Result<()>
Perform BitTorrent handshake over uTP
Sourcepub async fn send_message(&mut self, message: &[u8]) -> Result<()>
pub async fn send_message(&mut self, message: &[u8]) -> Result<()>
Send a BitTorrent message
Sourcepub async fn stats(&self) -> Result<ConnectionStats>
pub async fn stats(&self) -> Result<ConnectionStats>
Get connection statistics
Auto Trait Implementations§
impl !RefUnwindSafe for UtpPeerConnection
impl !UnwindSafe for UtpPeerConnection
impl Freeze for UtpPeerConnection
impl Send for UtpPeerConnection
impl Sync for UtpPeerConnection
impl Unpin for UtpPeerConnection
impl UnsafeUnpin for UtpPeerConnection
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