调整代码

This commit is contained in:
lbl8603
2024-06-04 23:00:27 +08:00
parent 5d228b9c27
commit 080e58eeb7
2 changed files with 5 additions and 2 deletions
+4 -2
View File
@@ -135,6 +135,7 @@ impl Compressor {
} }
#[test] #[test]
#[cfg(feature = "zstd_compress")]
fn test_lz4() { fn test_lz4() {
use crate::protocol::extension::{CompressionAlgorithm, ExtensionTailPacket}; use crate::protocol::extension::{CompressionAlgorithm, ExtensionTailPacket};
let lz4 = Compressor::Lz4; let lz4 = Compressor::Lz4;
@@ -166,7 +167,7 @@ fn test_lz4() {
unimplemented!() unimplemented!()
} }
}, },
ExtensionTailPacket::Unknown => { _ => {
unimplemented!() unimplemented!()
} }
} }
@@ -174,6 +175,7 @@ fn test_lz4() {
assert_eq!(in_packet.payload(), src_out_packet.payload()) assert_eq!(in_packet.payload(), src_out_packet.payload())
} }
#[test] #[test]
#[cfg(feature = "zstd_compress")]
fn test_zstd() { fn test_zstd() {
use crate::protocol::extension::{CompressionAlgorithm, ExtensionTailPacket}; use crate::protocol::extension::{CompressionAlgorithm, ExtensionTailPacket};
let zstd = Compressor::Zstd(22); let zstd = Compressor::Zstd(22);
@@ -209,7 +211,7 @@ fn test_zstd() {
unimplemented!() unimplemented!()
} }
}, },
ExtensionTailPacket::Unknown => { _ => {
unimplemented!() unimplemented!()
} }
} }
+1
View File
@@ -137,6 +137,7 @@ impl<B: AsRef<[u8]>> NetPacket<B> {
} }
Ok(NetPacket { data_len, buffer }) Ok(NetPacket { data_len, buffer })
} }
#[inline]
pub fn buffer(&self) -> &[u8] { pub fn buffer(&self) -> &[u8] {
&self.buffer.as_ref()[..self.data_len] &self.buffer.as_ref()[..self.data_len]
} }