Skip to content

Commit

Permalink
chore: fix clippy lints
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Guzik <[email protected]>
  • Loading branch information
Bravo555 committed Oct 18, 2024
1 parent 0748986 commit 5e635a8
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 25 deletions.
1 change: 1 addition & 0 deletions crates/common/batcher/src/batchable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::hash::Hash;
use time::OffsetDateTime;

/// Implement this interface for the items that you want batched.
///
/// No items with the same key will go in the same batch.
/// The event_time of the item will determine how items are grouped,
/// dependent on how the batcher is configured.
Expand Down
1 change: 1 addition & 0 deletions crates/common/flockfile/src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl FlockfileError {
}

/// flockfile creates a lockfile in the filesystem under `/run/lock` and then creates a filelock using system fcntl with flock.
///
/// flockfile will automatically remove lockfile on application exit and the OS should cleanup the filelock afterwards.
/// If application exits unexpectedly the filelock will be dropped, but the lockfile will not be removed unless handled in signal handler.
#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion crates/common/mqtt_channel/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl<'de> Deserialize<'de> for DebugPayload {
{
struct DebugPayloadVisitor;

impl<'de> serde::de::Visitor<'de> for DebugPayloadVisitor {
impl serde::de::Visitor<'_> for DebugPayloadVisitor {
type Value = DebugPayload;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion crates/common/tedge_utils/src/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ where

struct IsoOrUnixVisitor;

impl<'de> de::Visitor<'de> for IsoOrUnixVisitor {
impl de::Visitor<'_> for IsoOrUnixVisitor {
type Value = IsoOrUnix;

fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
Expand Down
2 changes: 2 additions & 0 deletions crates/common/upload/src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fn default_backoff() -> ExponentialBackoff {
}

/// Auto tries to detect the mime from the given file extension without direct file access.
///
/// Custom sets a custom Content-Type.
/// If multipart request is needed, choose FormData.
#[derive(Debug, Clone, Eq, PartialEq)]
Expand All @@ -40,6 +41,7 @@ pub enum ContentType {
}

/// Dataset to construct reqwest::multipart::Form.
///
/// To avoid using reqwest::multipart::Form inside the ContentType enum
/// since reqwest::multipart::Form doesn't support Copy or Clone.
/// If mime is None, the mime will be guessed while uploading a file.
Expand Down
10 changes: 7 additions & 3 deletions crates/core/c8y_api/src/smartrest/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::time::Duration;
use tedge_config::TopicPrefix;

/// Create a SmartREST message for creating a child device under the given ancestors.
///
/// The provided ancestors list must contain all the parents of the given device
/// starting from its immediate parent device.
pub fn child_device_creation_message(
Expand Down Expand Up @@ -141,9 +142,12 @@ impl From<C8ySmartRestSetInterval117> for MqttMessage {
}
}

/// Create a SmartREST payload for setting/updating the current state of the target profile
/// in its own managed object. When all individual operations are finished (i.e. firmware update, software update
/// and configuration update), the `profile_executed` field should be set to `true`, otherwise it should be `false`.
/// Create a SmartREST payload for setting/updating the current state of the
/// target profile in its own managed object.
///
/// When all individual operations are finished (i.e. firmware update, software
/// update and configuration update), the `profile_executed` field should be set
/// to `true`, otherwise it should be `false`.
pub fn set_c8y_profile_target_payload(profile_executed: bool) -> String {
fields_to_csv_string(&["121", &profile_executed.to_string()])
}
Expand Down
1 change: 1 addition & 0 deletions crates/core/c8y_api/src/smartrest/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ pub fn get_operation(path: PathBuf) -> Result<Operation, OperationsError> {

/// depending on which editor you use, temporary files could be created that contain the name of
/// the file.
///
/// this `operation_name_is_valid` fn will ensure that only files that do not contain
/// any special characters are allowed.
pub fn is_valid_operation_name(operation: &str) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions crates/core/c8y_api/src/smartrest/smartrest_serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,13 @@ impl C8yOperation for CumulocitySupportedOperations {
}
}

impl<'a> C8yOperation for &'a str {
impl C8yOperation for &str {
fn name(&self) -> &str {
self
}
}

impl<'a> C8yOperation for &'a String {
impl C8yOperation for &String {
fn name(&self) -> &str {
self.as_str()
}
Expand Down
7 changes: 2 additions & 5 deletions crates/core/tedge/src/bridge/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ impl BridgeConfig {
pub fn serialize<W: std::io::Write>(&self, writer: &mut W) -> std::io::Result<()> {
writeln!(writer, "### Bridge")?;
writeln!(writer, "connection {}", self.connection)?;
match &self.remote_username {
Some(name) => {
writeln!(writer, "remote_username {}", name)?;
}
None => {}
if let Some(name) = &self.remote_username {
writeln!(writer, "remote_username {}", name)?;
}
writeln!(writer, "address {}", self.address)?;

Expand Down
8 changes: 0 additions & 8 deletions crates/core/tedge_api/src/entity_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ use std::fmt::Display;
use std::path::Path;
use thiserror::Error;

/// Represents an "Entity topic identifier" portion of the MQTT topic
///
/// Example:
/// - topic: `te/device/dev1/service/myservice/m//my_measurement`
/// - entity id: `device/dev1/service/myservice`
///
/// <https://thin-edge.github.io/thin-edge.io/next/references/mqtt-api/#group-identifier>

// In the future, root will be read from config
const MQTT_ROOT: &str = "te";

Expand Down
6 changes: 3 additions & 3 deletions crates/core/tedge_api/src/measurement/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct ThinEdgeValueParser<'key, 'vis, T> {
visitor: &'vis mut T,
}

impl<'vis, 'de, T> de::Visitor<'de> for ThinEdgeJsonParser<'vis, T>
impl<'de, T> de::Visitor<'de> for ThinEdgeJsonParser<'_, T>
where
T: MeasurementVisitor,
{
Expand Down Expand Up @@ -119,7 +119,7 @@ where
}
}

impl<'key, 'vis, 'de, T> de::Visitor<'de> for ThinEdgeValueParser<'key, 'vis, T>
impl<'de, T> de::Visitor<'de> for ThinEdgeValueParser<'_, '_, T>
where
T: MeasurementVisitor,
{
Expand Down Expand Up @@ -240,7 +240,7 @@ where
///
/// As we are passing the parsed data over to the embedded visitor, all of our parsers do not
/// produce a value, so we use the empty tuple type.
impl<'key, 'vis, 'de, T> DeserializeSeed<'de> for ThinEdgeValueParser<'key, 'vis, T>
impl<'de, T> DeserializeSeed<'de> for ThinEdgeValueParser<'_, '_, T>
where
T: MeasurementVisitor,
{
Expand Down
2 changes: 1 addition & 1 deletion crates/core/tedge_write/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct CopyOptions<'a> {
pub group: Option<&'a str>,
}

impl<'a> CopyOptions<'a> {
impl CopyOptions<'_> {
/// Copies the file by spawning new tedge-write process.
///
/// Stdin and Stdout are UTF-8.
Expand Down
2 changes: 1 addition & 1 deletion crates/extensions/c8y_mapper_ext/src/operations/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl OperationHandler {
///
/// The panic in the operation task has to happen first, and then another message with the same
/// command id has to be handled for the call to `.handle()` to panic.

//
// but there's a problem: in practice, when a panic in a child task happens, .handle() will
// never get called for that operation again. Operation task itself sends the messages, so if
// they can't be sent over MQTT because of a panic, they won't be handled, won't be joined, so
Expand Down

0 comments on commit 5e635a8

Please sign in to comment.