From f0481e350d1bef2b1d10fd7e3bf8e997c7a29d05 Mon Sep 17 00:00:00 2001 From: Milo Turner Date: Mon, 9 Mar 2020 17:36:23 -0400 Subject: [PATCH] rename --- hptp/src/peer.rs | 16 ++++++++-------- hptp/src/seg.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hptp/src/peer.rs b/hptp/src/peer.rs index 7fbdb98..cb5d48d 100644 --- a/hptp/src/peer.rs +++ b/hptp/src/peer.rs @@ -4,10 +4,10 @@ use tokio::net::UdpSocket; use super::msg::{self, SerDes}; -pub struct Peer { +pub struct Peer { sock: UdpSocket, targ: Option, - _phantom: PhantomData T>, + _phantom: PhantomData R>, } pub type UpPeer = Peer; @@ -38,7 +38,7 @@ pub enum SendError { NoTarget, } -impl Peer { +impl Peer { pub fn new(sock: UdpSocket) -> Self { Peer { sock, @@ -51,9 +51,9 @@ impl Peer { self.targ = Some(addr); } - pub async fn send(&mut self, msg: F) -> Result<(), SendError> + pub async fn send(&mut self, msg: S) -> Result<(), SendError> where - F: SerDes, + S: SerDes, { let mut buf = [0u8; msg::MAX_TOTAL_PACKET_SIZE]; let len = msg.ser_to(&mut buf); @@ -62,13 +62,13 @@ impl Peer { Ok(()) } - pub async fn recv(&mut self) -> Result + pub async fn recv(&mut self) -> Result where - T: SerDes, + R: SerDes, { let mut buf = [0u8; msg::MAX_TOTAL_PACKET_SIZE]; let (len, who) = self.sock.recv_from(&mut buf).await?; self.set_known_target(who); - Ok(T::des(&buf[..len])?) + Ok(R::des(&buf[..len])?) } } diff --git a/hptp/src/seg.rs b/hptp/src/seg.rs index 550001f..50e2304 100644 --- a/hptp/src/seg.rs +++ b/hptp/src/seg.rs @@ -3,7 +3,7 @@ pub const MAX_TOTAL_PACKET_SIZE: usize = 1472; // TODO: change these based off the decoders pub const UP_HEADER_SIZE: usize = 0; -pub const DOWN_HEADER_SIZE: usize = 0; +pub const DOWN_HEADER_SIZE: usize = 1; /// This is the maximum amount of segment data we can fit into a packet. pub const MAX_SEG_SIZE: usize = MAX_TOTAL_PACKET_SIZE - UP_HEADER_SIZE;