forked from Proxmox/proxmox
clippy fix: the borrowed expression implements the required traits
See: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
This commit is contained in:
parent
b7a64cd4a2
commit
de6337ae6d
@ -293,7 +293,7 @@ impl APTRepositoryFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.repositories.is_empty() {
|
if self.repositories.is_empty() {
|
||||||
return std::fs::remove_file(&path)
|
return std::fs::remove_file(path)
|
||||||
.map_err(|err| self.err(format_err!("unable to remove file - {}", err)));
|
.map_err(|err| self.err(format_err!("unable to remove file - {}", err)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +414,7 @@ fn uri_to_filename(uri: &str) -> String {
|
|||||||
if *b <= 0x20 || *b >= 0x7F || encode_chars.contains(*b as char) {
|
if *b <= 0x20 || *b >= 0x7F || encode_chars.contains(*b as char) {
|
||||||
let mut hex = [0u8; 2];
|
let mut hex = [0u8; 2];
|
||||||
// unwrap: we're hex-encoding a single byte into a 2-byte slice
|
// unwrap: we're hex-encoding a single byte into a 2-byte slice
|
||||||
hex::encode_to_slice(&[*b], &mut hex).unwrap();
|
hex::encode_to_slice([*b], &mut hex).unwrap();
|
||||||
let hex = unsafe { std::str::from_utf8_unchecked(&hex) };
|
let hex = unsafe { std::str::from_utf8_unchecked(&hex) };
|
||||||
encoded = format!("{}%{}", encoded, hex);
|
encoded = format!("{}%{}", encoded, hex);
|
||||||
} else {
|
} else {
|
||||||
|
@ -97,7 +97,7 @@ pub fn store_auth_state(
|
|||||||
bail!("too many pending openid auth request for realm {}", realm);
|
bail!("too many pending openid auth request for realm {}", realm);
|
||||||
}
|
}
|
||||||
|
|
||||||
data.push(serde_json::to_value(&auth_state)?);
|
data.push(serde_json::to_value(auth_state)?);
|
||||||
|
|
||||||
replace_auth_state(&path, &data)?;
|
replace_auth_state(&path, &data)?;
|
||||||
|
|
||||||
|
@ -1023,11 +1023,11 @@ impl WorkerTaskContext for WorkerTask {
|
|||||||
|
|
||||||
fn log(&self, level: log::Level, message: &std::fmt::Arguments) {
|
fn log(&self, level: log::Level, message: &std::fmt::Arguments) {
|
||||||
match level {
|
match level {
|
||||||
log::Level::Error => self.log_warning(&message.to_string()),
|
log::Level::Error => self.log_warning(message.to_string()),
|
||||||
log::Level::Warn => self.log_warning(&message.to_string()),
|
log::Level::Warn => self.log_warning(message.to_string()),
|
||||||
log::Level::Info => self.log_message(&message.to_string()),
|
log::Level::Info => self.log_message(message.to_string()),
|
||||||
log::Level::Debug => self.log_message(&format!("DEBUG: {}", message)),
|
log::Level::Debug => self.log_message(format!("DEBUG: {}", message)),
|
||||||
log::Level::Trace => self.log_message(&format!("TRACE: {}", message)),
|
log::Level::Trace => self.log_message(format!("TRACE: {}", message)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ impl<T: fmt::Write> Serializer for ElementSerializer<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_str(mut self, v: &str) -> Result<Self::Ok, Error> {
|
fn serialize_str(mut self, v: &str) -> Result<Self::Ok, Error> {
|
||||||
if v.contains(&['"', '\\', '\n']) {
|
if v.contains(['"', '\\', '\n']) {
|
||||||
self.inner.write_char('"')?;
|
self.inner.write_char('"')?;
|
||||||
crate::property_string::quote(v, &mut self.inner)?;
|
crate::property_string::quote(v, &mut self.inner)?;
|
||||||
self.inner.write_char('"')?;
|
self.inner.write_char('"')?;
|
||||||
@ -643,7 +643,7 @@ impl<T: fmt::Write> ElementSerializeSeq<T> {
|
|||||||
|
|
||||||
fn finish(mut self) -> Result<T, Error> {
|
fn finish(mut self) -> Result<T, Error> {
|
||||||
let value = self.inner.finish()?;
|
let value = self.inner.finish()?;
|
||||||
if value.contains(&[',', ';', ' ', '"', '\\', '\n']) {
|
if value.contains([',', ';', ' ', '"', '\\', '\n']) {
|
||||||
self.output.write_char('"')?;
|
self.output.write_char('"')?;
|
||||||
crate::property_string::quote(&value, &mut self.output)?;
|
crate::property_string::quote(&value, &mut self.output)?;
|
||||||
self.output.write_char('"')?;
|
self.output.write_char('"')?;
|
||||||
|
@ -86,9 +86,8 @@ pub mod bytes_as_base64 {
|
|||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
String::deserialize(deserializer).and_then(|string| {
|
String::deserialize(deserializer)
|
||||||
base64::decode(&string).map_err(|err| Error::custom(err.to_string()))
|
.and_then(|string| base64::decode(string).map_err(|err| Error::custom(err.to_string())))
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +124,7 @@ pub mod string_as_base64 {
|
|||||||
fn finish_deserializing<'de, D: Deserializer<'de>>(string: String) -> Result<String, D::Error> {
|
fn finish_deserializing<'de, D: Deserializer<'de>>(string: String) -> Result<String, D::Error> {
|
||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
|
|
||||||
let bytes = base64::decode(&string).map_err(|err| {
|
let bytes = base64::decode(string).map_err(|err| {
|
||||||
let msg = format!("base64 decode: {}", err);
|
let msg = format!("base64 decode: {}", err);
|
||||||
Error::custom(msg)
|
Error::custom(msg)
|
||||||
})?;
|
})?;
|
||||||
@ -219,7 +218,7 @@ pub mod bytes_as_base64url_nopad {
|
|||||||
{
|
{
|
||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
String::deserialize(deserializer).and_then(|string| {
|
String::deserialize(deserializer).and_then(|string| {
|
||||||
base64::decode_config(&string, base64::URL_SAFE_NO_PAD)
|
base64::decode_config(string, base64::URL_SAFE_NO_PAD)
|
||||||
.map_err(|err| Error::custom(err.to_string()))
|
.map_err(|err| Error::custom(err.to_string()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ fn register_subscription<C: HttpClient<String, String>>(
|
|||||||
client: C,
|
client: C,
|
||||||
) -> Result<(String, String), Error> {
|
) -> Result<(String, String), Error> {
|
||||||
// WHCMS sample code feeds the key into this, but it's just a challenge, so keep it simple
|
// WHCMS sample code feeds the key into this, but it's just a challenge, so keep it simple
|
||||||
let rand = hex::encode(&proxmox_sys::linux::random_data(16)?);
|
let rand = hex::encode(proxmox_sys::linux::random_data(16)?);
|
||||||
let challenge = format!("{}{}", checktime, rand);
|
let challenge = format!("{}{}", checktime, rand);
|
||||||
|
|
||||||
let params = json!({
|
let params = json!({
|
||||||
|
Loading…
Reference in New Issue
Block a user