Skip to content

Commit

Permalink
cleanup: Manual clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxuser committed Oct 17, 2022
1 parent b8af859 commit 677de37
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 16 deletions.
4 changes: 2 additions & 2 deletions gamestreaming_native/src/packets/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub enum AudioPacketType {
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AudioCodec {
Opus = 0,
PCM = 1,
AAC = 2,
Pcm = 1,
Aac = 2,
}

bitflags! {
Expand Down
2 changes: 1 addition & 1 deletion gamestreaming_native/src/packets/mux_dct_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum ChannelType {
QoS,
}

#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ChannelPacket {
Audio(audio::AudioPacket),
Video(video::VideoPacket),
Expand Down
12 changes: 5 additions & 7 deletions pcap_parser/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl PcapParser {
if stun::message::is_message(payload) {
let mut stun_msg = stun::message::Message::new();
stun_msg.raw = payload.to_vec();
if let Ok(_) = stun_msg.decode() {
if stun_msg.decode().is_ok() {
println!("STUN Packet: {}", stun_msg);
} else {
println!("Malformed STUN packet");
Expand Down Expand Up @@ -211,7 +211,6 @@ fn main() {
} else {
let dummy_key = "RdHzuLLVGuO1aHILIEVJ1UzR7RWVioepmpy+9SRf";
crypto::MsSrtpCryptoContext::from_base64(dummy_key)
.ok()
.expect("Failed to init dummy crypto context")
}
};
Expand Down Expand Up @@ -256,10 +255,10 @@ fn main() {

let mut plaintext_eth_data: Vec<u8> = vec![];
plaintext_eth_data
.write(&pcap_packet.data[..datasize_until_ciphertext])
.write_all(&pcap_packet.data[..datasize_until_ciphertext])
.expect("Failed to write packet data until ciphertext");
plaintext_eth_data
.write(&plaintext)
.write_all(&plaintext)
.expect("Failed to write decrypted ciphertext portion");

// Save decrypted RTP packet to pcap out
Expand All @@ -275,9 +274,8 @@ fn main() {
}
} else {
// Write non-RTP packet as-is
match pcap_out_handle.as_mut() {
Some(savefile) => savefile.write(&pcap_packet),
None => {}
if let Some(savefile) = pcap_out_handle.as_mut() {
savefile.write(&pcap_packet)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions smartglass/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ impl SmartglassClient {
let client_builder = reqwest::ClientBuilder::new();
let client = client_builder
.user_agent(
user_agent.unwrap_or("Xbox/2008.0915.0311 CFNetwork/1197 Darwin/20.0.0".to_owned()),
user_agent.unwrap_or_else(||"Xbox/2008.0915.0311 CFNetwork/1197 Darwin/20.0.0".to_owned()),
)
.default_headers(headers)
.build()?;

Ok(Self {
session_id: session_id.unwrap_or(uuid::Uuid::new_v4()),
session_id: session_id.unwrap_or_else(uuid::Uuid::new_v4),
request_signer: request_signer::RequestSigner::default(),
ms_cv: CorrelationVector::default(),
client,
Expand Down
4 changes: 2 additions & 2 deletions teredo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ mod test {
let ipv6 = Ipv6Addr::from_str("2001:0:338c:24f4:43b:30e3:d2f3:c93d").unwrap();
let ipv6_not_teredo = Ipv6Addr::from_str("2019:0:338c:24f4:43b:30e3:d2f3:c93d").unwrap();

assert_eq!(ipv6.is_teredo(), true);
assert_eq!(ipv6_not_teredo.is_teredo(), false);
assert!(ipv6.is_teredo());
assert!(!ipv6_not_teredo.is_teredo());
}

#[test]
Expand Down
18 changes: 17 additions & 1 deletion xal/src/models.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::convert::Into;
use std::convert::From;

#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub enum DeviceType {
UNKNOWN,
IOS,
ANDROID,
WIN32,
}

impl From<&str> for DeviceType {
fn from(s: &str) -> Self {
match s.to_lowercase().as_ref() {
"android" => DeviceType::ANDROID,
"ios" => DeviceType::IOS,
"win32" => DeviceType::WIN32,
_ => DeviceType::UNKNOWN,
}
}
}

#[allow(clippy::from_over_into)]
impl<'a> Into<&'a str> for DeviceType {
fn into(self) -> &'a str {
match self {
DeviceType::ANDROID => "Android",
DeviceType::IOS => "iOS",
DeviceType::WIN32 => "Win32",
DeviceType::UNKNOWN => {
panic!("DeviceType::UNKNOWN should nevert be constructed")
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion xal/src/request_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl RequestSigner {
let signature = self
.sign(
self.signing_policy.version,
timestamp.unwrap_or(Utc::now()),
timestamp.unwrap_or_else(Utc::now),
to_sign,
)
.expect("Signing request failed!");
Expand Down Expand Up @@ -175,6 +175,7 @@ impl RequestSigner {
})
}

#[allow(clippy::too_many_arguments)]
fn assemble_message_data(
&self,
signing_policy_version: &[u8],
Expand Down

0 comments on commit 677de37

Please sign in to comment.