summaryrefslogtreecommitdiff
path: root/packet/src/buffer.rs
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2023-03-01 01:19:16 -0500
committerTyler Murphy <tylermurphy534@gmail.com>2023-03-01 01:19:16 -0500
commit6c62c26d0df243b00914de22cb8d30a8ba3e3eb4 (patch)
treeb54f1285f3491f9821718686ed3982cdac19d57e /packet/src/buffer.rs
parentinital working dns (diff)
downloadwrapper-6c62c26d0df243b00914de22cb8d30a8ba3e3eb4.tar.gz
wrapper-6c62c26d0df243b00914de22cb8d30a8ba3e3eb4.tar.bz2
wrapper-6c62c26d0df243b00914de22cb8d30a8ba3e3eb4.zip
clippy my beloved
Diffstat (limited to '')
-rw-r--r--packet/src/buffer.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/packet/src/buffer.rs b/packet/src/buffer.rs
index 3809781..4394705 100644
--- a/packet/src/buffer.rs
+++ b/packet/src/buffer.rs
@@ -6,8 +6,8 @@ pub struct PacketBuffer {
}
impl PacketBuffer {
- pub fn new() -> PacketBuffer {
- PacketBuffer {
+ pub fn new() -> Self {
+ Self {
buf: [0; 512],
pos: 0,
}
@@ -50,7 +50,7 @@ impl PacketBuffer {
if start + len >= 512 {
return Err("End of buffer".into());
}
- Ok(&self.buf[start..start + len as usize])
+ Ok(&self.buf[start..start + len])
}
pub fn read_u16(&mut self) -> Result<u16> {
@@ -63,7 +63,7 @@ impl PacketBuffer {
let res = ((self.read()? as u32) << 24)
| ((self.read()? as u32) << 16)
| ((self.read()? as u32) << 8)
- | ((self.read()? as u32) << 0);
+ | (self.read()? as u32);
Ok(res)
}
@@ -80,7 +80,7 @@ impl PacketBuffer {
// can craft a packet with a cycle in the jump instructions. This guards
// against such packets.
if jumps_performed > max_jumps {
- return Err(format!("Limit of {} jumps exceeded", max_jumps).into());
+ return Err(format!("Limit of {max_jumps} jumps exceeded").into());
}
let len = self.get(pos)?;
@@ -154,7 +154,7 @@ impl PacketBuffer {
self.write(((val >> 24) & 0xFF) as u8)?;
self.write(((val >> 16) & 0xFF) as u8)?;
self.write(((val >> 8) & 0xFF) as u8)?;
- self.write(((val >> 0) & 0xFF) as u8)?;
+ self.write((val & 0xFF) as u8)?;
Ok(())
}