A PLC Mirror written in Rust

clippy lints and a fmt run

+15 -12
-4
src/import.rs
··· 1 1 use crate::types::{PlcEntry, PlcOperationType}; 2 - use crate::utils::*; 3 - use chrono::{DateTime, Utc}; 4 2 use deadpool_postgres::{Object, Pool}; 5 - use ipld_core::cid::Cid; 6 3 use reqwest::Client; 7 - use serde::{Deserialize, Serialize}; 8 4 use slog::{Logger, debug, error}; 9 5 use std::env::var; 10 6 use std::time::{Duration, Instant};
+8 -3
src/lib.rs
··· 19 19 20 20 impl ApiContext { 21 21 pub async fn get_conn(&self) -> Result<Object, HttpError> { 22 - self.pool.get().await.map_err(|err| HttpError::for_internal_error(err.to_string())) 22 + self.pool 23 + .get() 24 + .await 25 + .map_err(|err| HttpError::for_internal_error(err.to_string())) 23 26 } 24 27 } 25 28 26 29 pub fn create_logger() -> eyre::Result<Logger> { 27 - let log = ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info } 28 - .to_logger("plc-mirror")?; 30 + let log = ConfigLogging::StderrTerminal { 31 + level: ConfigLoggingLevel::Info, 32 + } 33 + .to_logger("plc-mirror")?; 29 34 30 35 Ok(log) 31 36 }
+7 -5
src/types.rs
··· 1 1 use crate::utils::*; 2 + use chrono::{DateTime, Utc}; 2 3 use ipld_core::cid::Cid; 3 4 use schemars::schema::Schema; 4 5 use schemars::{JsonSchema, SchemaGenerator}; ··· 6 7 use std::borrow::Cow; 7 8 use std::collections::HashMap; 8 9 use std::fmt::{Debug, Display}; 9 - use chrono::{DateTime, Utc}; 10 10 11 11 const DID_DOC_JSONLD_CTX: &[&str] = &[ 12 12 "https://www.w3.org/ns/did/v1", ··· 72 72 } 73 73 74 74 #[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Deserialize, Serialize)] 75 - pub struct JsonCid(#[serde(deserialize_with = "cid_de_string", serialize_with = "cid_ser_string")] pub Cid); 75 + pub struct JsonCid( 76 + #[serde(deserialize_with = "cid_de_string", serialize_with = "cid_ser_string")] pub Cid, 77 + ); 76 78 77 79 // the default cid debugger outputs a byte array, which just sucks to read 78 80 impl Debug for JsonCid { ··· 81 83 } 82 84 } 83 85 84 - impl JsonCid { 85 - pub fn to_string(&self) -> String { 86 - self.0.to_string() 86 + impl Display for JsonCid { 87 + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 88 + Display::fmt(&self.0, f) 87 89 } 88 90 } 89 91