pub struct Handshake {
pub reserved: [u8; 8],
pub info_hash: Id20,
pub peer_id: Id20,
}Expand description
Peer wire handshake (BEP 3).
Format: <pstrlen><pstr><reserved><info_hash><peer_id>
- pstrlen: 1 byte (19)
- pstr: 19 bytes (“BitTorrent protocol”)
- reserved: 8 bytes (extension flags)
- info_hash: 20 bytes
- peer_id: 20 bytes
Fields§
§reserved: [u8; 8]8-byte reserved field for extension flags.
info_hash: Id20Info hash of the torrent.
peer_id: Id20Peer ID.
Implementations§
Source§impl Handshake
impl Handshake
Sourcepub fn new(info_hash: Id20, peer_id: Id20) -> Self
pub fn new(info_hash: Id20, peer_id: Id20) -> Self
Create a new handshake with extension protocol support (BEP 10).
Sourcepub fn supports_extensions(&self) -> bool
pub fn supports_extensions(&self) -> bool
Check if the peer supports the Extension Protocol (BEP 10).
Sourcepub fn supports_dht(&self) -> bool
pub fn supports_dht(&self) -> bool
Check if the peer supports DHT (BEP 5).
Sourcepub fn supports_fast(&self) -> bool
pub fn supports_fast(&self) -> bool
Check if the peer supports Fast Extension (BEP 6).
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Parse from bytes. Input must be exactly 68 bytes.
Trait Implementations§
impl Eq for Handshake
impl StructuralPartialEq for Handshake
Auto Trait Implementations§
impl Freeze for Handshake
impl RefUnwindSafe for Handshake
impl Send for Handshake
impl Sync for Handshake
impl Unpin for Handshake
impl UnsafeUnpin for Handshake
impl UnwindSafe for Handshake
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