Skip to content

Commit bb66bfd

Browse files
committed
fix: clippy
1 parent f8ce448 commit bb66bfd

File tree

6 files changed

+41
-50
lines changed

6 files changed

+41
-50
lines changed

src/api/metrics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ where
126126
}
127127
}
128128

129-
const TEXT_PLAIN_MIME: &'static str = "text/plain";
129+
const TEXT_PLAIN_MIME: &str = "text/plain";
130130

131131
// maybe this implementation is wrong as it removes bucket items aswell
132132
fn metrics_handler() -> impl Reply {
@@ -154,7 +154,7 @@ fn metrics_handler() -> impl Reply {
154154
.into_response()
155155
}
156156

157-
const METRICS_PATH: &'static str = "metrics";
157+
const METRICS_PATH: &str = "metrics";
158158

159159
pub(super) fn metrics(
160160
) -> impl Filter<Extract = impl Reply, Error = Rejection> + Clone + Send + 'static {

src/api/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,4 @@ where
104104
}
105105

106106
fn noop<T>(_: T) {
107-
()
108107
}

src/api/routes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ async fn register_handler(pool: PgPool) -> Result<impl Reply, Rejection> {
3636
Ok(res)
3737
}
3838

39-
const X_API_USER_HEADER: &'static str = "X-Api-User";
40-
const X_API_KEY_HEADER: &'static str = "X-Api-Key";
39+
const X_API_USER_HEADER: &str = "X-Api-User";
40+
const X_API_KEY_HEADER: &str = "X-Api-Key";
4141

4242
async fn update_handler(user: String, key: String, _pool: PgPool) -> Result<impl Reply, Rejection> {
4343
Ok(format!("{} {}", user, key))
4444
}
4545

46-
const REGISTER_PATH: &'static str = "register";
47-
const UPDATE_PATH: &'static str = "update";
46+
const REGISTER_PATH: &str = "register";
47+
const UPDATE_PATH: &str = "update";
4848

4949
pub(super) fn routes(
5050
pool: PgPool,

src/cert.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ impl CertManager {
257257

258258
let chall = order
259259
.authorizations()?
260-
.iter()
261-
.next()
260+
.get(0)
262261
.ok_or_else(|| anyhow!("couldn't unpack auths"))?
263262
.dns_challenge();
264263

src/config.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ impl<'de> Deserialize<'de> for ProxyProtocol {
2222
where
2323
D: Deserializer<'de>,
2424
{
25-
match bool::deserialize(deserializer) {
26-
Ok(true) => Ok(ProxyProtocol::Enabled),
27-
Ok(false) => Ok(ProxyProtocol::Disabled),
28-
Err(e) => Err(e),
25+
match bool::deserialize(deserializer)? {
26+
true => Ok(ProxyProtocol::Enabled),
27+
false => Ok(ProxyProtocol::Disabled),
2928
}
3029
}
3130
}

src/main.rs

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,46 +44,40 @@ fn run() -> Result<()> {
4444

4545
// Async closure cannot be move, if runtime gets moved into it
4646
// it gets dropped inside an async call
47-
let res: Result<()> = runtime.block_on(
48-
async {
49-
debug!("Running in runtime");
50-
51-
let pool = setup_database(&config.general.db).await?;
52-
let authority =
53-
DatabaseAuthority::new(pool.clone(), &config.general.name, config.records);
54-
let dns = DNS::new(&config.general.dns, authority);
55-
56-
let api = &config.api;
57-
let api = api::new(
58-
(api.http.clone(), api.http_proxy),
59-
(api.https.clone(), api.https_proxy),
60-
(api.prom.clone(), api.prom_proxy),
61-
pool.clone(),
62-
)
63-
.and_then(Api::spawn);
64-
65-
let persist = DatabasePersist::new(pool.clone(), &runtime);
66-
let cert_manager = CertManager::new(pool, persist, config.general.acme, &runtime)
67-
.and_then(CertManager::spawn);
68-
69-
info!("Starting API Cert Manager and DNS");
70-
tokio::select! {
71-
res = api => res,
72-
res = cert_manager => res,
73-
res = dns.spawn() => res,
74-
res = ctrl_c() => {
75-
res?;
76-
info!("Ctrl C pressed");
77-
Ok(())
78-
}
47+
let fut = async {
48+
debug!("Running in runtime");
49+
50+
let pool = setup_database(&config.general.db).await?;
51+
let authority = DatabaseAuthority::new(pool.clone(), &config.general.name, config.records);
52+
let dns = DNS::new(&config.general.dns, authority);
53+
54+
let api = &config.api;
55+
let api = api::new(
56+
(api.http.clone(), api.http_proxy),
57+
(api.https.clone(), api.https_proxy),
58+
(api.prom.clone(), api.prom_proxy),
59+
pool.clone(),
60+
)
61+
.and_then(Api::spawn);
62+
63+
let persist = DatabasePersist::new(pool.clone(), &runtime);
64+
let cert_manager = CertManager::new(pool, persist, config.general.acme, &runtime)
65+
.and_then(CertManager::spawn);
66+
67+
info!("Starting API Cert Manager and DNS");
68+
tokio::select! {
69+
res = api => res,
70+
res = cert_manager => res,
71+
res = dns.spawn() => res,
72+
res = ctrl_c() => {
73+
res?;
74+
info!("Ctrl C pressed");
75+
Ok(())
7976
}
8077
}
81-
.in_current_span(),
82-
);
83-
84-
res?;
78+
};
8579

86-
Ok(())
80+
runtime.block_on(fut.in_current_span())
8781
}
8882

8983
#[tracing::instrument(skip(db))]

0 commit comments

Comments
 (0)