Skip to content

Commit

Permalink
style: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
tirithen committed Nov 17, 2023
1 parent 53a6a66 commit 412c052
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/device/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};

use crate::{
tradfri_coap::TradfriConnection, BulbColdWarmHexUpdate, BulbParsed, BulbRgbXYUpdate,
BulbUpdate, Device, DeviceError, DeviceInfoParsed, DriverUpdate, LightDeviceParsed,
TradfriGateway, DeviceUpdate,
BulbUpdate, Device, DeviceError, DeviceInfoParsed, DeviceUpdate, DriverUpdate,
LightDeviceParsed, TradfriGateway,
};

#[derive(Debug)]
Expand Down
4 changes: 2 additions & 2 deletions src/device/parse.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};

use crate::{ColdWarmColor, RgbColor, serialization::bool_from_int};
use crate::{serialization::bool_from_int, ColdWarmColor, RgbColor};

#[derive(Debug, Deserialize, Serialize)]
pub struct DeviceTypeParsed {
Expand Down Expand Up @@ -133,4 +133,4 @@ pub struct BulbRgbXYParsed {
pub on: bool,
#[serde(rename = "5851")]
pub brightness: u8,
}
}
5 changes: 4 additions & 1 deletion src/device/update.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use serde::{Deserialize, Serialize};

use crate::{ColdWarmColor, RgbColor, serialization::{option_bool_from_int, option_int_from_bool}};
use crate::{
serialization::{option_bool_from_int, option_int_from_bool},
ColdWarmColor, RgbColor,
};

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(untagged)]
Expand Down
2 changes: 1 addition & 1 deletion src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use mdns_sd::{ServiceDaemon, ServiceEvent};
use crate::{
device::Device,
tradfri_coap::{TradfriAuthenticator, TradfriConnection},
DeviceUpdate, Group, GroupUpdate
DeviceUpdate, Group, GroupUpdate,
};

#[derive(Debug, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions src/group/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{TradfriGateway, tradfri_coap::TradfriConnection, TradfriGatewayError};
use crate::{tradfri_coap::TradfriConnection, TradfriGateway, TradfriGatewayError};

mod parse;
use chrono::{DateTime, Utc, TimeZone, NaiveDateTime};
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
pub use parse::*;

mod update;
Expand Down
2 changes: 1 addition & 1 deletion src/group/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ pub struct GroupParsed {
pub struct ItemsParsed {
// #[serde(rename = "15001")]
// pub items: Vec<Device>,
}
}
6 changes: 5 additions & 1 deletion src/group/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ use crate::serialization::option_int_from_bool;
pub struct GroupUpdate {
#[serde(rename = "5712", skip_serializing_if = "Option::is_none")]
pub transition_time: Option<u32>,
#[serde(rename = "5850", serialize_with = "option_int_from_bool", skip_serializing_if = "Option::is_none")]
#[serde(
rename = "5850",
serialize_with = "option_int_from_bool",
skip_serializing_if = "Option::is_none"
)]
pub on: Option<bool>,
#[serde(rename = "5851", skip_serializing_if = "Option::is_none")]
pub brightness: Option<u8>,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ mod color;
mod device;
mod gateway;
mod group;
mod serialization;
mod tradfri_coap;
mod udp_dtls;
mod serialization;

pub use crate::color::*;
pub use crate::device::*;
Expand Down
7 changes: 5 additions & 2 deletions src/serialization.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::{Deserialize, Deserializer, Serializer, de};
use serde::{de, Deserialize, Deserializer, Serializer};

pub(crate) fn option_bool_from_int<'de, D>(deserializer: D) -> Result<Option<bool>, D::Error>
where
Expand All @@ -14,7 +14,10 @@ where
}
}

pub(crate) fn option_int_from_bool<S>(value: &Option<bool>, serializer: S) -> Result<S::Ok, S::Error>
pub(crate) fn option_int_from_bool<S>(
value: &Option<bool>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
Expand Down

0 comments on commit 412c052

Please sign in to comment.