Skip to content

Commit

Permalink
Improved docs a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
manforowicz committed Dec 1, 2024
1 parent ace9846 commit f98aba5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
10 changes: 5 additions & 5 deletions gday_contact_exchange_protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
//! // an error message.
//! let request = ClientMsg::CreateRoom { room_code };
//! write_to(request, &mut tls_ipv4)?;
//! let response: ServerMsg = read_from(&mut tls_ipv4)?;
//! let ServerMsg::RoomCreated = read_from(&mut tls_ipv4)? else { panic!() };
//!
//! // Both peers sends ClientMsg::RecordPublicAddr
//! // from their IPv4 and/or IPv6 endpoints.
//! // The server records the client's public addresses from these connections.
//! // The server responds with ServerMsg::ReceivedAddr or an error message.
//! let request = ClientMsg::RecordPublicAddr { room_code, is_creator: true };
//! write_to(request, &mut tls_ipv4)?;
//! let response: ServerMsg = read_from(&mut tls_ipv4)?;
//! let ServerMsg::ReceivedAddr = read_from(&mut tls_ipv4)? else { panic!() };
//! write_to(request, &mut tls_ipv6)?;
//! let response: ServerMsg = read_from(&mut tls_ipv6)?;
//! let ServerMsg::ReceivedAddr = read_from(&mut tls_ipv6)? else { panic!() };
//!
//! // Both peers share their local address with the server.
//! // The server immediately responds with ServerMsg::ClientContact,
Expand All @@ -53,12 +53,12 @@
//! };
//! let request = ClientMsg::ReadyToShare { local_contact, room_code, is_creator: true };
//! write_to(request, &mut tls_ipv4)?;
//! let response: ServerMsg = read_from(&mut tls_ipv4)?;
//! let ServerMsg::ClientContact(my_contact) = read_from(&mut tls_ipv4)? else { panic!() };
//!
//! // Once both clients have sent ClientMsg::ReadyToShare,
//! // the server sends both clients a ServerMsg::PeerContact
//! // containing the FullContact of the peer.
//! let response: ServerMsg = read_from(&mut tls_ipv4)?;
//! let ServerMsg::PeerContact(peer_contact) = read_from(&mut tls_ipv4)? else { panic!() };
//!
//! // The server then closes the room, and the peers disconnect.
//!
Expand Down
1 change: 0 additions & 1 deletion gday_file_transfer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
//! #
//! # let rt = tokio::runtime::Builder::new_current_thread().build().unwrap();
//! # rt.block_on( async {
//!
//! # let (stream1, stream2) = tokio::io::duplex(64);
//! # let mut stream1 = tokio::io::BufReader::new(stream1);
//! # let mut stream2 = tokio::io::BufReader::new(stream2);
Expand Down
7 changes: 1 addition & 6 deletions gday_file_transfer/src/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use tokio::io::{
AsyncBufRead, AsyncBufReadExt, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt,
};
use tokio::io::{AsyncBufRead, AsyncBufReadExt, AsyncRead, AsyncWrite, AsyncWriteExt};

use crate::{Error, FileMeta, FileMetaLocal, FileOfferMsg, FileResponseMsg};
use std::io::{ErrorKind, Seek, SeekFrom};
Expand Down Expand Up @@ -147,9 +145,6 @@ pub async fn receive_files(
return Err(Error::UnexpectedFileLen);
}

// only take the length of the remaining part of the file from the reader
let mut reader = (&mut reader).take(offer.len - start);

net_to_file(&mut reader, &mut file, offer.len - start).await?;
}
reader.progress.processed_files += 1;
Expand Down

0 comments on commit f98aba5

Please sign in to comment.