From c00676feba3819883b2888799d5f743c4ca9bca0 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 13 Sep 2022 12:25:37 +0200 Subject: [PATCH] Uniformize flag naming --- src/recv.rs | 4 ++-- src/send.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/recv.rs b/src/recv.rs index 8909190..0de7bef 100644 --- a/src/recv.rs +++ b/src/recv.rs @@ -91,8 +91,8 @@ pub(crate) trait RecvLoop: Sync + 'static { continue; } - let has_cont = (size & CHUNK_HAS_CONTINUATION) != 0; - let is_error = (size & ERROR_MARKER) != 0; + let has_cont = (size & CHUNK_FLAG_HAS_CONTINUATION) != 0; + let is_error = (size & CHUNK_FLAG_ERROR) != 0; let size = (size & CHUNK_LENGTH_MASK) as usize; let mut next_slice = vec![0; size as usize]; read.read_exact(&mut next_slice[..]).await?; diff --git a/src/send.rs b/src/send.rs index 0ca62fd..af5f00c 100644 --- a/src/send.rs +++ b/src/send.rs @@ -19,8 +19,8 @@ use crate::stream::*; // Chunk format: // - u32 BE: request id (same for request and response) // - u16 BE: chunk length + flags: -// CHUNK_HAS_CONTINUATION when this is not the last chunk of the stream -// ERROR_MARKER if this chunk denotes an error +// CHUNK_FLAG_HAS_CONTINUATION when this is not the last chunk of the stream +// CHUNK_FLAG_ERROR if this chunk denotes an error // (these two flags are exclusive, an error denotes the end of the stream) // **special value** 0xFFFF indicates a CANCEL message // - [u8; chunk_length], either @@ -28,14 +28,14 @@ use crate::stream::*; // - if error: // - u8: error kind, encoded using error::io_errorkind_to_u8 // - rest: error message -// - absent for cancel message +// - absent for cancel messag pub(crate) type RequestID = u32; pub(crate) type ChunkLength = u16; pub(crate) const MAX_CHUNK_LENGTH: ChunkLength = 0x3FF0; -pub(crate) const ERROR_MARKER: ChunkLength = 0x4000; -pub(crate) const CHUNK_HAS_CONTINUATION: ChunkLength = 0x8000; +pub(crate) const CHUNK_FLAG_ERROR: ChunkLength = 0x4000; +pub(crate) const CHUNK_FLAG_HAS_CONTINUATION: ChunkLength = 0x8000; pub(crate) const CHUNK_LENGTH_MASK: ChunkLength = 0x3FFF; pub(crate) const CANCEL_REQUEST: ChunkLength = 0xFFFF; @@ -237,8 +237,8 @@ impl DataFrame { fn header(&self) -> [u8; 2] { let header_u16 = match self { DataFrame::Data(data, false) => data.len() as u16, - DataFrame::Data(data, true) => data.len() as u16 | CHUNK_HAS_CONTINUATION, - DataFrame::Error(msg) => msg.len() as u16 | ERROR_MARKER, + DataFrame::Data(data, true) => data.len() as u16 | CHUNK_FLAG_HAS_CONTINUATION, + DataFrame::Error(msg) => msg.len() as u16 | CHUNK_FLAG_ERROR, }; ChunkLength::to_be_bytes(header_u16) }