From 6624df1e4426c61b9539bd7161d6e542fdd18b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 16 Oct 2021 01:53:28 +0200 Subject: [PATCH] aquatic_ws_protocol: add documentation (as comments) --- aquatic_ws_protocol/src/lib.rs | 12 ++++++++++++ aquatic_ws_protocol/src/request/mod.rs | 1 + aquatic_ws_protocol/src/response/mod.rs | 11 ++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/aquatic_ws_protocol/src/lib.rs b/aquatic_ws_protocol/src/lib.rs index f3650bc..e2971f7 100644 --- a/aquatic_ws_protocol/src/lib.rs +++ b/aquatic_ws_protocol/src/lib.rs @@ -1,3 +1,15 @@ +//! WebTorrent protocol implementation +//! +//! Typical announce workflow: +//! - Peer A sends announce request with info hash and offers +//! - Tracker sends on offers to other peers announcing with that info hash and +//! sends back announce response to peer A +//! - Tracker receives answers to those offers from other peers and send them +//! on to peer A +//! +//! Typical scrape workflow +//! - Peer sends scrape request and receives scrape response + pub mod common; pub mod request; pub mod response; diff --git a/aquatic_ws_protocol/src/request/mod.rs b/aquatic_ws_protocol/src/request/mod.rs index 8412c78..8f067c3 100644 --- a/aquatic_ws_protocol/src/request/mod.rs +++ b/aquatic_ws_protocol/src/request/mod.rs @@ -7,6 +7,7 @@ pub mod scrape; pub use announce::*; pub use scrape::*; +/// Message received by tracker #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(untagged)] pub enum InMessage { diff --git a/aquatic_ws_protocol/src/response/mod.rs b/aquatic_ws_protocol/src/response/mod.rs index b00c9ce..363eeae 100644 --- a/aquatic_ws_protocol/src/response/mod.rs +++ b/aquatic_ws_protocol/src/response/mod.rs @@ -12,14 +12,15 @@ pub use error::*; pub use offer::*; pub use scrape::*; +/// Message sent by tracker #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(untagged)] pub enum OutMessage { - Offer(offer::MiddlemanOfferToPeer), - Answer(answer::MiddlemanAnswerToPeer), - AnnounceResponse(announce::AnnounceResponse), - ScrapeResponse(scrape::ScrapeResponse), - ErrorResponse(error::ErrorResponse), + Offer(MiddlemanOfferToPeer), + Answer(MiddlemanAnswerToPeer), + AnnounceResponse(AnnounceResponse), + ScrapeResponse(ScrapeResponse), + ErrorResponse(ErrorResponse), } impl OutMessage {