diff --git a/Cargo.lock b/Cargo.lock index 35faafb..1e1db03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1358,6 +1358,7 @@ dependencies = [ "palette", "rayon", "rgb", + "thiserror", "tokio", ] @@ -1852,18 +1853,18 @@ checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2" [[package]] name = "thiserror" -version = "1.0.62" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.62" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d20468752b09f49e909e55a5d338caa8bedf615594e9d80bc4c565d30faf798c" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 45cdc67..250ceb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,4 +20,5 @@ num-traits = "0.2.19" palette = "0.7.6" rayon = "1.10.0" rgb = "0.8.40" +thiserror = "1.0.63" tokio = { version = "1.38.1", features = ["full"] } diff --git a/src/api.rs b/src/api.rs index b61f66e..6cdfe07 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,7 +1,21 @@ -use axum::{Router}; +use axum::{extract::State, http::StatusCode, routing::post, Router}; + +use crate::display::Wrapper; +use std::sync::{Arc, Mutex}; +#[derive(Clone)] +struct ApiContext { + display: Arc>, +} /// API routes for axum /// Start with the basics: Send an image, crop it, dither, and upload. /// we defer the upload to a separate task. +pub fn router() -> Router { + Router::new() + .route("/setimage", post(set_image)) +} + +async fn set_image(State(ctx): State) { +} diff --git a/src/errors.rs b/src/errors.rs new file mode 100644 index 0000000..5aed0b5 --- /dev/null +++ b/src/errors.rs @@ -0,0 +1 @@ +use thiserror; diff --git a/src/main.rs b/src/main.rs index 79d666c..8473627 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ pub mod display; pub mod imageproc; pub mod api; +pub mod errors; use crate::display::Wrapper; use crate::imageproc::{DiffusionMatrix, Ditherer, EInkImage, ErrorDiffusionDither}; @@ -48,5 +49,8 @@ async fn main() -> anyhow::Result<()> { display.test()?; } + if matches!(cli.command, Command::Serve) { + } + Ok(()) }