Skip to content

Commit

Permalink
Fix clippy lints (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
flxo authored Jun 4, 2024
1 parent 74aa3d4 commit ca3686f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
12 changes: 8 additions & 4 deletions northstar-runtime/src/common/version.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use serde::{Deserialize, Serialize};
use std::{cmp::Ordering, fmt, str::FromStr};
use std::{
cmp::Ordering,
fmt::{self, Display},
str::FromStr,
};
use thiserror::Error;

/// Parsing error
Expand Down Expand Up @@ -164,9 +168,9 @@ impl FromStr for VersionReq {
}
}

impl ToString for VersionReq {
fn to_string(&self) -> String {
self.inner.to_string()
impl Display for VersionReq {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.inner)
}
}

Expand Down
10 changes: 0 additions & 10 deletions northstar-runtime/src/npk/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,6 @@ impl FromStr for Manifest {
}
}

impl ToString for Manifest {
#[allow(clippy::unwrap_used)]
fn to_string(&self) -> String {
// A `Manifest` is convertible to `String` as long as its implementation of `Serialize` does
// not return an error. This should never happen for the types that we use in `Manifest` so
// we can safely use .unwrap() here.
serde_yaml::to_string(self).expect("failed to serialize manifest")
}
}

/// Validate manifest.
fn validate(manifest: &Manifest) -> Result<(), ValidationError> {
// Most optionals in the manifest are not valid for a resource container
Expand Down
3 changes: 2 additions & 1 deletion northstar-runtime/src/npk/npk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,8 @@ impl<'a> NpkBuilder<'a> {
zip.set_comment(meta_str);

// Add manifest.
let manifest_str = manifest.to_string();
let manifest_str =
serde_yaml::to_string(manifest).context("failed to serialize manifest")?;
zip.start_file(MANIFEST_NAME, options)
.context("failed to write manifest to NPK")?;
zip.write_all(manifest_str.as_bytes())
Expand Down
1 change: 1 addition & 0 deletions northstar-runtime/src/runtime/ipc/raw_fd_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::{io, io::Result, os::unix::prelude::AsRawFd};

pub trait RawFdExt: AsRawFd {
/// Returns true of self is set to non-blocking.
#[allow(unused)]
fn is_nonblocking(&self) -> Result<bool>;

/// Set non-blocking mode.
Expand Down
1 change: 1 addition & 0 deletions northstar-runtime/src/runtime/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod cgroups;
mod console;
mod debug;
#[allow(unused)]
mod devicemapper;
mod env;
mod error;
Expand Down

0 comments on commit ca3686f

Please sign in to comment.