diff --git a/src/http/accept.rs b/src/http/accept.rs index dd5779a..6925981 100644 --- a/src/http/accept.rs +++ b/src/http/accept.rs @@ -17,7 +17,7 @@ where { type Rejection = (StatusCode, &'static str); - async fn from_request_parts(parts: &mut Parts, state: &S) -> Result { + async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result { if let Some(user_agent) = parts.headers.get(ACCEPT) { Ok(ExtractAccept(user_agent.clone())) } else { diff --git a/src/node/container.rs b/src/node/container.rs index 0dda524..5ccc85e 100644 --- a/src/node/container.rs +++ b/src/node/container.rs @@ -27,7 +27,7 @@ impl From for ContainerInfo { fn from(value: ContainerInspectResponse) -> Self { ContainerInfo { name: value.name.unwrap(), - state: value.state.map(|s| s.status).flatten().unwrap().to_string(), + state: value.state.and_then(|s| s.status).unwrap().to_string(), image: value.image.unwrap(), } } diff --git a/src/node/error.rs b/src/node/error.rs index 2e52cf8..a5d9852 100644 --- a/src/node/error.rs +++ b/src/node/error.rs @@ -8,9 +8,9 @@ pub enum StackError { NotFound, } -impl Into for StackError { - fn into(self) -> AppError { - match self { +impl From for AppError { + fn from(value: StackError) -> Self { + match value { StackError::NotFound => AppError::Client { status: StatusCode::NOT_FOUND, code: "stack-not-found", diff --git a/src/node/stack.rs b/src/node/stack.rs index 7c6b403..4c96d66 100644 --- a/src/node/stack.rs +++ b/src/node/stack.rs @@ -2,12 +2,12 @@ use super::error::StackError; use crate::http::error::Result; use bollard::{container::ListContainersOptions, service::ContainerSummary, Docker}; use serde::Serialize; -use std::{collections::HashMap, path::PathBuf}; +use std::{collections::HashMap, path::Path}; use tokio::fs::{read_dir, try_exists}; const COMPOSE_FILE: &str = "arion-compose.nix"; -async fn is_stack(dir: &PathBuf) -> Result { +async fn is_stack(dir: &Path) -> Result { Ok(try_exists(dir.join(COMPOSE_FILE)).await?) } @@ -25,7 +25,7 @@ pub async fn get_containers(docker: &Docker, stack_name: &str) -> Result Result { +pub async fn get_compose(base_dir: &Path, stack_name: &str) -> Result { let dir = base_dir.join(stack_name); if !is_stack(&dir).await? { return Err(StackError::NotFound.into()); @@ -41,7 +41,7 @@ pub struct StackInfo { pub active: bool, } -pub async fn list(base_dir: &PathBuf, docker: &Docker) -> Result> { +pub async fn list(base_dir: &Path, docker: &Docker) -> Result> { let containers = docker .list_containers(Some(ListContainersOptions { all: false, @@ -65,8 +65,7 @@ pub async fn list(base_dir: &PathBuf, docker: &Docker) -> Result> let project = cont .clone() .labels - .map(|lab| lab.get("com.docker.compose.project").cloned()) - .flatten() + .and_then(|lab| lab.get("com.docker.compose.project").cloned()) .unwrap_or_default(); name == project });