aboutsummaryrefslogtreecommitdiff
path: root/src/common.rs
diff options
context:
space:
mode:
authorLizzy Fleckenstein <eliasfleckenstein@web.de>2023-02-26 03:02:06 +0100
committerLizzy Fleckenstein <eliasfleckenstein@web.de>2023-02-26 03:02:11 +0100
commita4c3c05c69a4f9de76e41980594d180ec9ffe03b (patch)
treeec693be8e4f30bfc927b8e5aef329fbea969cc56 /src/common.rs
parent1954496f73f0a22ff173e2869ed187b6f74d8777 (diff)
downloadmt_rudp-a4c3c05c69a4f9de76e41980594d180ec9ffe03b.tar.xz
Implement sending splits
Diffstat (limited to 'src/common.rs')
-rw-r--r--src/common.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common.rs b/src/common.rs
index bdae6d2..9d99cb9 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -52,3 +52,17 @@ pub struct Pkt<'a> {
pub chan: u8,
pub data: Cow<'a, [u8]>,
}
+
+impl<'a> Pkt<'a> {
+ pub fn size(&self) -> usize {
+ self.header_size() + self.body_size()
+ }
+
+ pub fn body_size(&self) -> usize {
+ self.data.len()
+ }
+
+ pub fn header_size(&self) -> usize {
+ 4 + 2 + 1 + if self.unrel { 0 } else { 1 + 2 } + 1
+ }
+}