pub struct AnnounceRequest<'a> {
pub info_hash: InfoHashV1,
pub peer_id: [u8; 20],
pub port: u16,
pub uploaded: u64,
pub downloaded: u64,
pub left: u64,
pub event: Option<AnnounceEvent>,
pub numwant: Option<u32>,
pub key: Option<u32>,
pub tracker_id: Option<&'a [u8]>,
}Expand description
Caller-supplied announce facts, not a torrent lifecycle or counter policy. Port zero, full u64 counters, and explicit numwant/key zero are representable. No IP override, random identity/key generation or event inference is added.
Fields§
§info_hash: InfoHashV1§peer_id: [u8; 20]§port: u16§uploaded: u64§downloaded: u64§left: u64§event: Option<AnnounceEvent>§numwant: Option<u32>§key: Option<u32>§tracker_id: Option<&'a [u8]>Implementations§
Source§impl AnnounceRequest<'_>
impl AnnounceRequest<'_>
Sourcepub fn encode_query(
&self,
existing_query: Option<&str>,
max_output_len: usize,
) -> Result<String, QueryError>
pub fn encode_query( &self, existing_query: Option<&str>, max_output_len: usize, ) -> Result<String, QueryError>
Build a raw query WITHOUT a leading ?, not a URL or HTTP request.
existing_query is the URL parser’s raw query (without ? or fragment).
Unknown parameters, duplicates and escape spelling are preserved exactly.
Reserved generated keys are rejected even when absent from this request,
including percent-escaped spellings, to avoid ambiguous duplicate fields.
Keys are case-sensitive. Existing query bytes must obey ASCII URI query
syntax with valid percent escapes; empty segments and flag-only keys are
tolerated. This validates query syntax only, not tracker authentication.
Binary values are escaped ONCE: only ASCII alphanumerics and - remain
literal, matching the deployed baseline; all other bytes use uppercase
%HH (including space, plus, NUL and non-UTF-8). compact=1 is always sent;
responses may still be noncompact. Empty tracker IDs are omitted.
The cap covers preserved query + appended fields. Writes stop at the
cap; no unbounded intermediate encoding is built. Install the result
with a URL library’s RAW query setter, not form/query-pair serialization
that would re-escape %. URL validation and total URL limits belong to
that caller. Never log this query indiscriminately: it may hold secrets.