mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
[Crate] Apply strict clippy on buffer
This commit is contained in:
parent
4ff50ea711
commit
5aa2ce99ec
1 changed files with 5 additions and 6 deletions
|
|
@ -29,7 +29,7 @@ impl<'a, B: ByteOrder> Buffer<'a, B> {
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `data` - A byte slice that the buffer will read from.
|
/// * `data` - A byte slice that the buffer will read from.
|
||||||
pub(crate) fn new(data: &'a [u8]) -> Self {
|
pub(crate) const fn new(data: &'a [u8]) -> Self {
|
||||||
Self {
|
Self {
|
||||||
data,
|
data,
|
||||||
cursor: 0,
|
cursor: 0,
|
||||||
|
|
@ -37,14 +37,14 @@ impl<'a, B: ByteOrder> Buffer<'a, B> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn current_position(&self) -> usize { self.cursor }
|
pub(crate) const fn current_position(&self) -> usize { self.cursor }
|
||||||
|
|
||||||
/// Returns the length of the remaining bytes from the current cursor
|
/// Returns the length of the remaining bytes from the current cursor
|
||||||
/// position.
|
/// position.
|
||||||
pub(crate) fn remaining_length(&self) -> usize { self.data.len() - self.cursor }
|
pub(crate) const fn remaining_length(&self) -> usize { self.data.len() - self.cursor }
|
||||||
|
|
||||||
/// Returns the length of the buffer data.
|
/// Returns the length of the buffer data.
|
||||||
pub(crate) fn data_length(&self) -> usize { self.data.len() }
|
pub(crate) const fn data_length(&self) -> usize { self.data.len() }
|
||||||
|
|
||||||
// Added for legacy support just for the refactoring
|
// Added for legacy support just for the refactoring
|
||||||
// Not Tested
|
// Not Tested
|
||||||
|
|
@ -109,8 +109,7 @@ impl<'a, B: ByteOrder> Buffer<'a, B> {
|
||||||
// because we don't have enough data left to read.
|
// because we don't have enough data left to read.
|
||||||
if size > remaining {
|
if size > remaining {
|
||||||
return Err(PacketUnderflow.context(format!(
|
return Err(PacketUnderflow.context(format!(
|
||||||
"Size requested {} was larger than remaining bytes {}",
|
"Size requested {size} was larger than remaining bytes {remaining}"
|
||||||
size, remaining
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue