aboutsummaryrefslogtreecommitdiff
path: root/src/proto.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-12 18:13:07 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-12 18:13:07 +0200
commitd9bd1182f7b980df8e631ae8eeca444f5d997909 (patch)
tree9345b078b2225c2fd58074ef3016ea6524d0ab3f /src/proto.rs
parentf87dbe73dc12f2d6eb13850a3bc4b012aadd3c9b (diff)
downloadnetapp-d9bd1182f7b980df8e631ae8eeca444f5d997909.tar.gz
netapp-d9bd1182f7b980df8e631ae8eeca444f5d997909.zip
Move out things from conn.rs into two separate files
Diffstat (limited to 'src/proto.rs')
-rw-r--r--src/proto.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/proto.rs b/src/proto.rs
index 5b71ba5..3811e3f 100644
--- a/src/proto.rs
+++ b/src/proto.rs
@@ -38,11 +38,19 @@ pub const PRIO_PRIMARY: RequestPriority = 0x00;
/// Priority: secondary among given class (ex: `PRIO_HIGH | PRIO_SECONDARY`)
pub const PRIO_SECONDARY: RequestPriority = 0x01;
+// Messages are sent by chunks
+// Chunk format:
+// - u32 BE: request id (same for request and response)
+// - u16 BE: chunk length, possibly with CHUNK_HAS_CONTINUATION flag
+// when this is not the last chunk of the message
+// - [u8; chunk_length] chunk data
+
pub(crate) type RequestID = u32;
type ChunkLength = u16;
const MAX_CHUNK_LENGTH: ChunkLength = 0x4000;
const CHUNK_HAS_CONTINUATION: ChunkLength = 0x8000;
+
struct SendQueueItem {
id: RequestID,
prio: RequestPriority,
@@ -86,12 +94,6 @@ impl SendQueue {
}
}
-// Messages are sent by chunks
-// Chunk format:
-// - u32 BE: request id (same for request and response)
-// - u16 BE: chunk length
-// - [u8; chunk_length] chunk data
-
#[async_trait]
pub(crate) trait SendLoop: Sync {
async fn send_loop<W>(