refactor: clippy fixs

This commit is contained in:
Cain 2024-01-18 18:59:19 +00:00
parent bedd277027
commit b1e42f9023
4 changed files with 13 additions and 13 deletions

View file

@ -304,7 +304,7 @@ fn output_result_bson_base64<T: serde::Serialize>(result: T) {
if let bson::Bson::Document(document) = bson {
let bytes = bson::to_vec(&document).unwrap();
println!("{}", base64::prelude::BASE64_STANDARD.encode(&bytes));
println!("{}", base64::prelude::BASE64_STANDARD.encode(bytes));
} else {
panic!("Failed to convert result to BSON Base64");
}

View file

@ -24,9 +24,9 @@ pub(crate) enum Direction {
#[derive(Clone, Copy, Debug, PartialEq)]
pub(crate) enum Protocol {
/// Transmission Control Protocol.
TCP,
Tcp,
/// User Datagram Protocol.
UDP,
Udp,
}
/// Trait for handling different types of IP addresses (IPv4, IPv6).
@ -41,7 +41,7 @@ pub(crate) trait IpAddress: Sized {
pub(crate) struct CapturePacket<'a> {
/// Direction of the packet (Send/Receive).
pub(crate) direction: Direction,
/// Protocol of the packet (TCP/UDP).
/// Protocol of the packet (Tcp/UDP).
pub(crate) protocol: Protocol,
/// Remote socket address.
pub(crate) remote_address: &'a SocketAddr,
@ -135,14 +135,14 @@ mod tests {
fn test_ports_by_direction() {
let packet_send = CapturePacket {
direction: Direction::Send,
protocol: Protocol::TCP,
protocol: Protocol::Tcp,
local_address: &socket_addr("127.0.0.1:8080"),
remote_address: &socket_addr("192.168.1.1:80"),
};
let packet_receive = CapturePacket {
direction: Direction::Receive,
protocol: Protocol::TCP,
protocol: Protocol::Tcp,
local_address: &socket_addr("127.0.0.1:8080"),
remote_address: &socket_addr("192.168.1.1:80"),
};
@ -155,14 +155,14 @@ mod tests {
fn test_ip_addr() {
let packet_send = CapturePacket {
direction: Direction::Send,
protocol: Protocol::TCP,
protocol: Protocol::Tcp,
local_address: &socket_addr("127.0.0.1:8080"),
remote_address: &socket_addr("192.168.1.1:80"),
};
let packet_receive = CapturePacket {
direction: Direction::Receive,
protocol: Protocol::TCP,
protocol: Protocol::Tcp,
local_address: &socket_addr("127.0.0.1:8080"),
remote_address: &socket_addr("192.168.1.1:80"),
};
@ -187,7 +187,7 @@ mod tests {
fn test_ip_by_direction_type_specific() {
let packet = CapturePacket {
direction: Direction::Send,
protocol: Protocol::TCP,
protocol: Protocol::Tcp,
local_address: &socket_addr("127.0.0.1:8080"),
remote_address: &socket_addr("192.168.1.1:80"),
};

View file

@ -56,7 +56,7 @@ impl<W: Write> Pcap<W> {
let (source_port, dest_port) = info.ports_by_direction();
match info.protocol {
Protocol::TCP => {
Protocol::Tcp => {
let buf_size = {
let mut tcp = MutableTcpPacket::new(&mut buf).unwrap();
tcp.set_source(source_port);
@ -123,7 +123,7 @@ impl<W: Write> Pcap<W> {
vec![EnhancedPacketOption::Comment("Generated TCP ACK".into())],
);
}
Protocol::UDP => {
Protocol::Udp => {
let buf_size = {
let mut udp = MutableUdpPacket::new(&mut buf).unwrap();
udp.set_source(source_port);

View file

@ -210,13 +210,13 @@ pub mod capture {
/// Represents the TCP protocol provider.
pub(crate) struct ProtocolTCP;
impl ProtocolProvider for ProtocolTCP {
fn protocol() -> Protocol { Protocol::TCP }
fn protocol() -> Protocol { Protocol::Tcp }
}
/// Represents the UDP protocol provider.
pub(crate) struct ProtocolUDP;
impl ProtocolProvider for ProtocolUDP {
fn protocol() -> Protocol { Protocol::UDP }
fn protocol() -> Protocol { Protocol::Udp }
}
/// A socket wrapper that allows capturing packets.