Skip to content

Commit

Permalink
Remove byteorder, use bytes::Buf::get_uint instead
Browse files Browse the repository at this point in the history
  • Loading branch information
nylonicious committed Dec 23, 2024
1 parent b7a7817 commit 53585ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ __rustls-tls = ["rustls", "rustls-pki-types"]

[dependencies]
data-encoding = { version = "2", optional = true }
byteorder = "1.3.2"
bytes = "1.9.0"
http = { version = "1.0", optional = true }
httparse = { version = "1.3.4", optional = true }
Expand Down
16 changes: 6 additions & 10 deletions src/protocol/frame/frame.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use byteorder::{NetworkEndian, ReadBytesExt};
use log::*;
use std::{
default::Default,
Expand All @@ -18,7 +17,7 @@ use crate::{
error::{Error, ProtocolError, Result},
protocol::frame::Utf8Bytes,
};
use bytes::{Bytes, BytesMut};
use bytes::{Buf, Bytes, BytesMut};

/// A struct representing the close command.
#[derive(Debug, Clone, Eq, PartialEq)]
Expand Down Expand Up @@ -161,14 +160,11 @@ impl FrameHeader {
let length_byte = second & 0x7F;
let length_length = LengthFormat::for_byte(length_byte).extra_bytes();
if length_length > 0 {
match cursor.read_uint::<NetworkEndian>(length_length) {
Err(ref err) if err.kind() == ErrorKind::UnexpectedEof => {
return Ok(None);
}
Err(err) => {
return Err(err.into());
}
Ok(read) => read,
let mut buffer = [0; 8];
match cursor.read_exact(&mut buffer[..length_length]) {
Err(ref err) if err.kind() == ErrorKind::UnexpectedEof => return Ok(None),
Err(err) => return Err(err.into()),
Ok(()) => buffer[..length_length].as_ref().get_uint(length_length),
}
} else {
u64::from(length_byte)
Expand Down

0 comments on commit 53585ac

Please sign in to comment.