Skip to main content

KrpcQuery

Enum KrpcQuery 

Source
pub enum KrpcQuery {
    Ping {
        id: Id20,
    },
    FindNode {
        id: Id20,
        target: Id20,
        want: Option<Vec<WantFamily>>,
    },
    GetPeers {
        id: Id20,
        info_hash: Id20,
        noseed: Option<i64>,
        scrape: Option<i64>,
        want: Option<Vec<WantFamily>>,
    },
    AnnouncePeer {
        id: Id20,
        info_hash: Id20,
        port: u16,
        implied_port: bool,
        token: Vec<u8>,
    },
    Get {
        id: Id20,
        target: Id20,
        seq: Option<i64>,
    },
    Put {
        id: Id20,
        token: Vec<u8>,
        value: Vec<u8>,
        key: Option<[u8; 32]>,
        signature: Option<[u8; 64]>,
        seq: Option<i64>,
        salt: Option<Vec<u8>>,
        cas: Option<i64>,
    },
    SampleInfohashes {
        id: Id20,
        target: Id20,
    },
}
Expand description

KRPC query types (BEP 5).

Variants§

§

Ping

Liveness check.

Fields

§id: Id20

Querying node’s ID.

§

FindNode

Find the closest nodes to a target ID.

Fields

§id: Id20

Querying node’s ID.

§target: Id20

Target node ID to search for.

§want: Option<Vec<WantFamily>>

BEP 45: requested address families.

§

GetPeers

Find peers downloading a torrent.

Fields

§id: Id20

Querying node’s ID.

§info_hash: Id20

Torrent info hash to search for.

§noseed: Option<i64>

BEP 33: if set to 1, exclude seed peers from results.

§scrape: Option<i64>

BEP 33: if set to 1, include bloom filter scrape data in response.

§want: Option<Vec<WantFamily>>

BEP 45: requested address families.

§

AnnouncePeer

Announce that we are downloading a torrent.

Fields

§id: Id20

Querying node’s ID.

§info_hash: Id20

Torrent info hash being announced.

§port: u16

Port we are listening on.

§implied_port: bool

If true, use the UDP source port instead of the port field.

§token: Vec<u8>

Write token obtained from a prior get_peers response.

§

Get

BEP 44: get an item from DHT storage.

Fields

§id: Id20

Querying node’s ID.

§target: Id20

Target hash: SHA-1(value) for immutable, SHA-1(pubkey+salt) for mutable.

§seq: Option<i64>

Optional: if set, only return mutable items with seq > this value.

§

Put

BEP 44: put an item into DHT storage.

Fields

§id: Id20

Querying node’s ID.

§token: Vec<u8>

Write token (obtained from a prior get response).

§value: Vec<u8>

The bencoded value to store.

§key: Option<[u8; 32]>

For mutable items: ed25519 public key (32 bytes).

§signature: Option<[u8; 64]>

For mutable items: ed25519 signature (64 bytes).

§seq: Option<i64>

For mutable items: sequence number.

§salt: Option<Vec<u8>>

For mutable items: optional salt.

§cas: Option<i64>

For mutable items: optional CAS (compare-and-swap) expected seq.

§

SampleInfohashes

BEP 51: sample info hashes from a node’s storage.

Fields

§id: Id20

Querying node’s ID.

§target: Id20

Target ID for DHT traversal.

Implementations§

Source§

impl KrpcQuery

Source

pub fn method_name(&self) -> &'static str

The query method name as used in the q field.

Source

pub fn sender_id(&self) -> &Id20

The querying node’s ID.

Trait Implementations§

Source§

impl Clone for KrpcQuery

Source§

fn clone(&self) -> KrpcQuery

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KrpcQuery

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for KrpcQuery

Source§

impl PartialEq for KrpcQuery

Source§

fn eq(&self, other: &KrpcQuery) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for KrpcQuery

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more