Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove clippy warnings #36

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use hard_xml::XmlRead;
use omaha;

#[rustfmt::skip]
const RESPONSE_XML: &'static str =
const RESPONSE_XML: &str =
r#"<?xml version="1.0" encoding="UTF-8"?>
<response protocol="3.0" server="nebraska">
<daystart elapsed_seconds="0"/>
Expand Down Expand Up @@ -45,8 +45,9 @@ fn main() -> Result<(), Box<dyn Error>> {
println!(" package {}:", pkg.name);

#[rustfmt::skip]
pkg.hash.as_ref()
.map(|h| println!(" sha1: {}", h));
if let Some(h) = pkg.hash.as_ref() {
println!(" sha1: {}", h);
};

#[rustfmt::skip]
let hash_sha256 = pkg.hash_sha256
Expand Down
8 changes: 4 additions & 4 deletions omaha/src/hash_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<T: HashAlgo> fmt::Debug for Hash<T> {
let hash_hex = Hex::encode_to_string(self.0.as_ref())
.map_err(|_| fmt::Error)?;

f.debug_tuple(&*tn).field(&hash_hex).finish()
f.debug_tuple(&tn).field(&hash_hex).finish()
}
}

Expand All @@ -72,10 +72,10 @@ impl<T: HashAlgo> str::FromStr for Hash<T> {
}
}

impl<T: HashAlgo> Into<Vec<u8>> for Hash<T> {
fn into(self) -> Vec<u8> {
impl<T: HashAlgo> From<Hash<T>> for Vec<u8> {
fn from(val: Hash<T>) -> Self {
let mut vec = Vec::new();
vec.append(&mut self.0.as_ref().to_vec());
vec.append(&mut val.0.as_ref().to_vec());
vec
}
}
Expand Down
38 changes: 16 additions & 22 deletions omaha/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ impl<'__input: 'a, 'a> hard_xml::XmlRead<'__input> for Manifest<'a> {
reader.read_till_element_start("manifest")?;

while let Some((k, v)) = reader.find_attribute()? {
match k {
"version" => __self_version = Some(v),
_ => ()
if k == "version" {
__self_version = Some(v);
}
}

Expand All @@ -169,7 +168,7 @@ impl<'__input: 'a, 'a> hard_xml::XmlRead<'__input> for Manifest<'a> {
"packages" => {
reader.read_till_element_start("packages")?;

while let Some(_) = reader.find_attribute()? {}
while (reader.find_attribute()?).is_some() {}

if let Token::ElementEnd { end: ElementEnd::Empty, .. }
= reader.next().unwrap()?
Expand All @@ -196,7 +195,7 @@ impl<'__input: 'a, 'a> hard_xml::XmlRead<'__input> for Manifest<'a> {
"actions" => {
reader.read_till_element_start("actions")?;

while let Some(_) = reader.find_attribute()? {}
while (reader.find_attribute()?).is_some() {}

if let Token::ElementEnd { end: ElementEnd::Empty, .. }
= reader.next().unwrap()?
Expand Down Expand Up @@ -227,15 +226,15 @@ impl<'__input: 'a, 'a> hard_xml::XmlRead<'__input> for Manifest<'a> {
}
}

return Ok(Manifest {
Ok(Manifest {
version: __self_version
.ok_or(XmlError::MissingField {
name: "Manifest".to_owned(),
field: "version".to_owned(),
})?,
packages: __self_packages,
actions: __self_actions,
});
})
}
}
#[derive(Debug)]
Expand All @@ -260,9 +259,8 @@ impl<'__input: 'a, 'a> hard_xml::XmlRead<'__input> for UpdateCheck<'a> {
reader.read_till_element_start("updatecheck")?;

while let Some((k, v)) = reader.find_attribute()? {
match k {
"status" => __self_status = Some(v),
_ => {}
if k == "status" {
__self_status = Some(v);
}
}

Expand All @@ -289,7 +287,7 @@ impl<'__input: 'a, 'a> hard_xml::XmlRead<'__input> for UpdateCheck<'a> {
"urls" => {
reader.read_till_element_start("urls")?;

while let Some(_) = reader.find_attribute()? {}
while (reader.find_attribute()?).is_some() {}
if let Token::ElementEnd { end: ElementEnd::Empty, .. }
= reader.next().unwrap()?
{
Expand All @@ -301,15 +299,11 @@ impl<'__input: 'a, 'a> hard_xml::XmlRead<'__input> for UpdateCheck<'a> {
"url" => {
reader.read_till_element_start("url")?;
while let Some((k, v)) = reader.find_attribute()? {
match k {
"codebase" => {
__self_urls.push(
Url::from_str(&v)
.map_err(|e| XmlError::FromStr(e.into()))?,
)
}

_ => {}
if k == "codebase" {
__self_urls.push(
Url::from_str(&v)
.map_err(|e| XmlError::FromStr(e.into()))?,
)
}
}

Expand Down Expand Up @@ -337,7 +331,7 @@ impl<'__input: 'a, 'a> hard_xml::XmlRead<'__input> for UpdateCheck<'a> {
}
}

return Ok(UpdateCheck {
Ok(UpdateCheck {
status: __self_status
.ok_or(XmlError::MissingField {
name: "UpdateCheck".to_owned(),
Expand All @@ -349,7 +343,7 @@ impl<'__input: 'a, 'a> hard_xml::XmlRead<'__input> for UpdateCheck<'a> {
name: "UpdateCheck".to_owned(),
field: "manifest".to_owned(),
})?,
});
})
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/bin/download_sysext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ impl<'a> Package<'a> {

if self.hash != calculated {
self.status = PackageStatus::BadChecksum;
return false;
false
} else {
self.status = PackageStatus::Unverified;
return true;
true
}
}

Expand Down Expand Up @@ -311,7 +311,7 @@ impl Args {
let mut builder = GlobSetBuilder::new();

for m in &*self.image_match {
builder.add(Glob::new(&*m)?);
builder.add(Glob::new(m)?);
}

builder.build()
Expand Down
14 changes: 6 additions & 8 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::borrow::Cow;

use anyhow::{Context, Result};
use hard_xml::XmlWrite;
use omaha;

//
// SERVER=https://public.update.flatcar-linux.net/v1/update/
Expand All @@ -13,13 +12,12 @@ use omaha;
// FLATCAR_RELEASE_APPID={e96281a6-d1af-4bde-9a0a-97b76e56dc57}
//

const UPDATE_URL: &'static str = "https://public.update.flatcar-linux.net/v1/update/";
const PROTOCOL_VERSION: &'static str = "3.0";
// const UPDATER_VERSION_STR: &'static str = "update-engine-0.4.10";
const UPDATER_VERSION_STR: &'static str = "ue-rs-0.0.0";
const UPDATE_URL: &str = "https://public.update.flatcar-linux.net/v1/update/";
const PROTOCOL_VERSION: &str = "3.0";
const UPDATER_VERSION_STR: &str = "ue-rs-0.0.0";

const OS_PLATFORM: &'static str = "CoreOS";
const OS_VERSION: &'static str = "Chateau";
const OS_PLATFORM: &str = "CoreOS";
const OS_VERSION: &str = "Chateau";

const APP_ID: omaha::Uuid = omaha::uuid!("{e96281a6-d1af-4bde-9a0a-97b76e56dc57}");

Expand Down Expand Up @@ -83,5 +81,5 @@ pub async fn perform<'a>(client: &reqwest::Client, parameters: Parameters<'a>) -
.await
.context("client post send({UPDATE_URL}) failed")?;

Ok(resp.text().await.context("failed to get response")?)
resp.text().await.context("failed to get response")
}
1 change: 0 additions & 1 deletion test/crau_verify.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::io::{BufReader, Write};
use std::error::Error;
use std::fs;
use tempfile;

use update_format_crau::delta_update;

Expand Down
Loading