Skip to content

Commit

Permalink
refactor: use format_args!() when String creation is unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
Integral-Tech committed Dec 21, 2024
1 parent 520859c commit 7bf9ce7
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions livetwo/src/rtspclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,24 @@ impl RtspSession {
}

fn generate_digest_response(&self, realm: &str, nonce: &str, method: &str) -> String {
let ha1 = format!("{:x}", {
format!("{:x}", {

Check warning on line 55 in livetwo/src/rtspclient.rs

View check run for this annotation

Codecov / codecov/patch

livetwo/src/rtspclient.rs#L55

Added line #L55 was not covered by tests
let mut hasher = Md5::new();
hasher.update(format!(
"{}:{}:{}",
self.auth_params.username, realm, self.auth_params.password
format_args!("{:x}", {
let hasher = Md5::new_with_prefix(format!(
"{}:{}:{}",
self.auth_params.username, realm, self.auth_params.password
));
hasher.finalize()
}),
nonce,
format_args!("{:x}", {
let hasher = Md5::new_with_prefix(format!("{}:{}", method, self.uri));
hasher.finalize()
})

Check warning on line 70 in livetwo/src/rtspclient.rs

View check run for this annotation

Codecov / codecov/patch

livetwo/src/rtspclient.rs#L59-L70

Added lines #L59 - L70 were not covered by tests
));
hasher.finalize()
});

let ha2 = format!("{:x}", {
let mut hasher = Md5::new();
hasher.update(format!("{}:{}", method, self.uri));
hasher.finalize()
});

format!("{:x}", {
let mut hasher = Md5::new();
hasher.update(format!("{}:{}:{}", ha1, nonce, ha2));
hasher.finalize()
})
}

Expand Down

0 comments on commit 7bf9ce7

Please sign in to comment.