diff --git a/crates/buffers/src/lib.rs b/crates/buffers/src/lib.rs index d6ced8e..b45c891 100644 --- a/crates/buffers/src/lib.rs +++ b/crates/buffers/src/lib.rs @@ -1,3 +1,8 @@ +// This crate used for making working with &[u8] or Vec generic in other parts of librqbit, +// for nicer display of binary data etc. +// +// Not useful outside of librqbit. + use serde::{Deserialize, Deserializer}; use clone_to_owned::CloneToOwned; diff --git a/crates/clone_to_owned/src/lib.rs b/crates/clone_to_owned/src/lib.rs index e661cd0..561033f 100644 --- a/crates/clone_to_owned/src/lib.rs +++ b/crates/clone_to_owned/src/lib.rs @@ -1,3 +1,11 @@ +// These are helpers for objects that can be borrowed, but can be made owned while changing the type. +// The difference between e.g. Cow and CloneToOwned, is that we can implement it recursively for owned types. +// +// E.g. HashMap<&str, &str> can be converted to HashMap. +// +// This lets us express types like TorrentMetaInfo<&[u8]> for zero-copy metadata about a bencode buffer in memory, +// but to have one-line conversion for it into TorrentMetaInfo> so that we can store it later somewhere. + use std::collections::HashMap; pub trait CloneToOwned { diff --git a/crates/peer_binary_protocol/src/lib.rs b/crates/peer_binary_protocol/src/lib.rs index 0ba8a57..2535ac7 100644 --- a/crates/peer_binary_protocol/src/lib.rs +++ b/crates/peer_binary_protocol/src/lib.rs @@ -1,3 +1,7 @@ +// BitTorrent peer protocol implementation: parsing, serialization etc. +// +// Can be used outside of librqbit. + pub mod extended; use bincode::Options; diff --git a/crates/sha1w/src/lib.rs b/crates/sha1w/src/lib.rs index 036bed9..116b6f2 100644 --- a/crates/sha1w/src/lib.rs +++ b/crates/sha1w/src/lib.rs @@ -1,8 +1,9 @@ -// Wrapper for sha1 libraries. -// Sha1 computation is the majority of CPU usage of this library. -// openssl seems 2-3x faster, so using it for now, but -// leaving the pure-rust impl here too. Maybe someday make them -// runtime swappable or enabled with a feature. +// Wrapper for sha1 libraries to be able to swap them easily, +// e.g. to measure performance, or change implementations depending on platform. +// +// Sha1 computation is the majority of CPU usage of librqbit. +// openssl is 2-3x faster than rust's sha1. +// system library is the best choice probably (it's the default anyway). #[cfg(feature = "sha1-openssl")] pub type Sha1 = Sha1Openssl;