Skip to content

Commit

Permalink
feat: fix formatting
Browse files Browse the repository at this point in the history
Signed-off-by: callum-ryan <[email protected]>
  • Loading branch information
callum-ryan committed Dec 28, 2024
1 parent 397799a commit b106b18
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 17 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "bright"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand All @@ -18,4 +17,4 @@ tokio = { version = "1.42.0", features = ["macros", "rt", "rt-multi-thread"] }

[dependencies.openssl-sys]
version = "0.9"
features = ["vendored"]
features = ["vendored"]
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
check-fmt:
cargo +nightly fmt --all -- --check

check-clippy:
cargo clippy --all-targets --all-features --workspace -- -D warnings

install-cargo-sort:
cargo install [email protected]

cargo-sort: install-cargo-sort
cargo sort -c -w

install-cargo-machete:
cargo install cargo-machete

cargo-machete: install-cargo-machete
cargo machete

check: check-fmt check-clippy cargo-sort cargo-machete
9 changes: 9 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
edition = "2021"
reorder_imports = true

format_code_in_doc_comments = true
group_imports = "StdExternalCrate"
imports_granularity = "Module"
overflow_delimited_expr = true
trailing_comma = "Vertical"
where_single_line = true
3 changes: 1 addition & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use chrono::{DateTime, Local};
use clap::builder::StringValueParser;
use clap::builder::TypedValueParser;
use clap::builder::{StringValueParser, TypedValueParser};
use clap::Parser;

#[derive(Parser, Debug)]
Expand Down
23 changes: 11 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use clap::Parser;
use log::debug;
use reqwest::header;
use std::collections::HashMap;
use std::fs::File;
use std::io::Write;
use std::time::{Duration, SystemTime, UNIX_EPOCH};

use clap::Parser;
use log::debug;
use reqwest::header;
mod cli;
mod models;
use crate::cli::Cli;
use crate::models::{Entity, Reading, ResourceQuery};
use chrono::{DateTime, Local, TimeZone};
use influxdb::InfluxDbWriteable;

use chrono::{DateTime, Local, TimeZone};
use crate::cli::Cli;
use crate::models::{Entity, Reading, ResourceQuery};

const GLOWMARKT_AUTH_URI: &str = "https://api.glowmarkt.com/api/v0-1/auth";
const GLOWMARKT_APP_ID: &str = "b0f1b774-a586-4f72-9edd-27ead8aa7a8d";
Expand Down Expand Up @@ -72,12 +73,10 @@ async fn main() {
fn min_dates<Tz: TimeZone>(d1: DateTime<Tz>, d2: DateTime<Tz>) -> DateTime<Tz> {
let d1_unix = d1.timestamp();
let d2_unix = d2.timestamp();
if d1_unix < d2_unix {
d1
} else if d1_unix > d2_unix {
d2
} else {
d1
match d1_unix.cmp(&d2_unix) {
std::cmp::Ordering::Less => d1,
std::cmp::Ordering::Greater => d2,
std::cmp::Ordering::Equal => d1,
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/models.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::collections::HashMap;

use chrono::TimeZone;
use influxdb::InfluxDbWriteable;
use serde::Deserialize;
use std::collections::HashMap;

#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
Expand Down

0 comments on commit b106b18

Please sign in to comment.