Skip to content

Commit

Permalink
Sarthak | Removes unused constant
Browse files Browse the repository at this point in the history
  • Loading branch information
SarthakMakhija committed Jul 14, 2024
1 parent 30538a4 commit f8b90be
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/key_value.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use std::io::{Error, Read};
use std::mem;

use bytes::{Buf, BufMut, BytesMut};

const U16_SIZE: usize = mem::size_of::<u16>();

pub(crate) struct KeyValue {
key: Vec<u8>,
value: Vec<u8>,
Expand All @@ -14,7 +11,7 @@ impl KeyValue {
pub fn new(key: Vec<u8>, value: Vec<u8>) -> KeyValue {
assert!(key.len() > 0);
assert!(value.len() > 0);
KeyValue {key, value}
KeyValue { key, value }
}

pub(crate) fn encode(&self) -> BytesMut {
Expand All @@ -23,7 +20,7 @@ impl KeyValue {
buffer.put_u16_le(self.value.len() as u16);
buffer.put_slice(&self.key);
buffer.put_slice(&self.value);
return buffer
return buffer;
}

pub(crate) fn decode_from(mut buffer: BytesMut) -> Result<KeyValue, Error> {
Expand All @@ -40,7 +37,7 @@ impl KeyValue {
value.resize(value_length as usize, 0);
buffer_reader.read_exact(&mut value)?;

return Ok(KeyValue::new(key, value))
return Ok(KeyValue::new(key, value));
}
}

Expand Down

0 comments on commit f8b90be

Please sign in to comment.