subscription: clippy lints

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2022-07-20 13:07:18 +02:00 committed by Wolfgang Bumiller
parent baf31dc2d8
commit 3f694b5481

View File

@ -102,8 +102,7 @@ impl SubscriptionInfo {
.as_object_mut() .as_object_mut()
.ok_or_else(|| format_err!("subscription info not a JSON object"))? .ok_or_else(|| format_err!("subscription info not a JSON object"))?
.remove("signature") .remove("signature")
.map(|v| v.as_str().map(|v| v.to_owned())) .and_then(|v| v.as_str().map(|v| v.to_owned()));
.flatten();
if self.is_signed() && signature.is_none() { if self.is_signed() && signature.is_none() {
bail!("Failed to extract signature value!"); bail!("Failed to extract signature value!");
@ -188,7 +187,7 @@ impl SubscriptionInfo {
} }
(None, _) => { (None, _) => {
self.status = SubscriptionStatus::Invalid; self.status = SubscriptionStatus::Invalid;
self.message = Some(format!("Missing server ID.")); self.message = Some("Missing server ID.".to_string());
self.signature = None; self.signature = None;
} }
(Some(contained), Ok(expected)) if &expected != contained => { (Some(contained), Ok(expected)) if &expected != contained => {
@ -217,7 +216,7 @@ impl SubscriptionInfo {
}; };
if self.is_signed() { if self.is_signed() {
if let Err(err) = verify(&self) { if let Err(err) = verify(self) {
self.status = SubscriptionStatus::Invalid; self.status = SubscriptionStatus::Invalid;
self.message = Some(format!("Signature validation failed - {err}")); self.message = Some(format!("Signature validation failed - {err}"));
} }
@ -242,7 +241,7 @@ pub fn get_hardware_address() -> Result<String, Error> {
} }
fn parse_next_due(value: &str) -> Result<i64, Error> { fn parse_next_due(value: &str) -> Result<i64, Error> {
let mut components = value.split("-"); let mut components = value.split('-');
let year = components let year = components
.next() .next()
.ok_or_else(|| format_err!("missing year component."))? .ok_or_else(|| format_err!("missing year component."))?