From 7e227bfb0954bc093fb949515fd99d5965ba50ca Mon Sep 17 00:00:00 2001 From: Divma <26765164+divagant-martian@users.noreply.github.com> Date: Thu, 12 Jun 2025 11:31:49 -0500 Subject: [PATCH] rename frame's write and read methods to the more used encode and decode (#91) --- quinn-proto/src/connection/mod.rs | 2 +- quinn-proto/src/frame.rs | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index aae3a8a9e..131599639 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -4165,7 +4165,7 @@ impl Connection { } None => break, }; - frame::RetireConnectionId { path_id, sequence }.write(buf); + frame::RetireConnectionId { path_id, sequence }.encode(buf); sent.retransmits .get_or_create() .retire_cids diff --git a/quinn-proto/src/frame.rs b/quinn-proto/src/frame.rs index 94a0d8afd..7946248c4 100644 --- a/quinn-proto/src/frame.rs +++ b/quinn-proto/src/frame.rs @@ -270,7 +270,7 @@ pub(crate) struct RetireConnectionId { impl RetireConnectionId { // TODO(@divma): docs - pub(crate) fn write(&self, buf: &mut W) { + pub(crate) fn encode(&self, buf: &mut W) { buf.write(self.get_type()); if let Some(id) = self.path_id { buf.write(id); @@ -280,7 +280,7 @@ impl RetireConnectionId { // TODO(@divma): docs // should only be called after the frame type has been verified - pub(crate) fn read(bytes: &mut R, read_path: bool) -> coding::Result { + pub(crate) fn decode(bytes: &mut R, read_path: bool) -> coding::Result { Ok(Self { path_id: if read_path { Some(bytes.get()?) } else { None }, sequence: bytes.get()?, @@ -817,7 +817,7 @@ impl Iter { error_code: self.bytes.get()?, }), FrameType::RETIRE_CONNECTION_ID | FrameType::PATH_RETIRE_CONNECTION_ID => { - Frame::RetireConnectionId(RetireConnectionId::read( + Frame::RetireConnectionId(RetireConnectionId::decode( &mut self.bytes, ty == FrameType::PATH_RETIRE_CONNECTION_ID, )?) @@ -890,10 +890,10 @@ impl Iter { let observed = ObservedAddr::read(&mut self.bytes, is_ipv6)?; Frame::ObservedAddr(observed) } - FrameType::PATH_ABANDON => Frame::PathAbandon(PathAbandon::read(&mut self.bytes)?), + FrameType::PATH_ABANDON => Frame::PathAbandon(PathAbandon::decode(&mut self.bytes)?), FrameType::PATH_BACKUP | FrameType::PATH_AVAILABLE => { let is_backup = ty == FrameType::PATH_BACKUP; - Frame::PathAvailable(PathAvailable::read(&mut self.bytes, is_backup)?) + Frame::PathAvailable(PathAvailable::decode(&mut self.bytes, is_backup)?) } FrameType::MAX_PATH_ID => Frame::MaxPathId(self.bytes.get()?), FrameType::PATHS_BLOCKED => Frame::PathsBlocked(self.bytes.get()?), @@ -1288,7 +1288,7 @@ pub(crate) struct PathAbandon { #[allow(dead_code)] // TODO(flub) impl PathAbandon { // TODO(@divma): docs - pub(crate) fn write(&self, buf: &mut W) { + pub(crate) fn encode(&self, buf: &mut W) { buf.write(FrameType::PATH_ABANDON); buf.write(self.path_id); buf.write(self.error_code); @@ -1296,7 +1296,7 @@ impl PathAbandon { // TODO(@divma): docs // should only be called after the frame type has been verified - pub(crate) fn read(bytes: &mut R) -> coding::Result { + pub(crate) fn decode(bytes: &mut R) -> coding::Result { Ok(Self { path_id: bytes.get()?, error_code: bytes.get()?, @@ -1315,7 +1315,7 @@ pub(crate) struct PathAvailable { #[allow(dead_code)] // TODO(flub) impl PathAvailable { // TODO(@divma): docs - pub(crate) fn write(&self, buf: &mut W) { + pub(crate) fn encode(&self, buf: &mut W) { buf.write(self.get_type()); buf.write(self.path_id); buf.write(self.status_seq_no); @@ -1323,7 +1323,7 @@ impl PathAvailable { // TODO(@divma): docs // should only be called after the frame type has been verified - pub(crate) fn read(bytes: &mut R, is_backup: bool) -> coding::Result { + pub(crate) fn decode(bytes: &mut R, is_backup: bool) -> coding::Result { Ok(Self { is_backup, path_id: bytes.get()?, @@ -1470,7 +1470,7 @@ mod test { error_code: TransportErrorCode::NO_ERROR, }; let mut buf = Vec::new(); - abandon.write(&mut buf); + abandon.encode(&mut buf); let mut decoded = frames(buf); assert_eq!(decoded.len(), 1); @@ -1488,7 +1488,7 @@ mod test { status_seq_no: VarInt(73), }; let mut buf = Vec::new(); - path_avaiable.write(&mut buf); + path_avaiable.encode(&mut buf); let mut decoded = frames(buf); assert_eq!(decoded.len(), 1); @@ -1525,7 +1525,7 @@ mod test { sequence: 31, }; let mut buf = Vec::new(); - retire_cid.write(&mut buf); + retire_cid.encode(&mut buf); let mut decoded = frames(buf); assert_eq!(decoded.len(), 1);