pub struct ExtHandshake {
pub m: BTreeMap<String, u8>,
pub v: Option<String>,
pub p: Option<u16>,
pub reqq: Option<u32>,
pub metadata_size: Option<u64>,
pub upload_only: Option<u8>,
}Expand description
Extension handshake (BEP 10, ext_id=0).
Exchanged after the standard handshake to negotiate extension IDs.
Fields§
§m: BTreeMap<String, u8>Map of extension name → assigned message ID.
v: Option<String>Client name.
p: Option<u16>TCP listen port for incoming connections.
reqq: Option<u32>Number of outstanding request queue size.
metadata_size: Option<u64>Total size of metadata (for ut_metadata).
upload_only: Option<u8>BEP 21: upload-only flag (1 = seeder, 0 or absent = leecher).
Implementations§
Source§impl ExtHandshake
impl ExtHandshake
Sourcepub fn new_with_plugins(plugin_names: &[&str]) -> Self
pub fn new_with_plugins(plugin_names: &[&str]) -> Self
Create a handshake advertising built-in + plugin extensions.
Built-in extensions are assigned IDs 1–4. Plugin names are assigned IDs starting at 10, in the order provided.
Sourcepub fn new_upload_only() -> Self
pub fn new_upload_only() -> Self
Create a handshake advertising upload-only (BEP 21 seeder) status.
Sourcepub fn is_upload_only(&self) -> bool
pub fn is_upload_only(&self) -> bool
Returns true if the peer declared BEP 21 upload-only status.
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Decode from bencode bytes.
Uses lenient parsing to accept unsorted dictionary keys, which many real-world clients send in their extension handshakes.
Trait Implementations§
Source§impl Clone for ExtHandshake
impl Clone for ExtHandshake
Source§fn clone(&self) -> ExtHandshake
fn clone(&self) -> ExtHandshake
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more