diff --git a/Cargo.lock b/Cargo.lock index 2f56176..35faafb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -692,6 +692,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + [[package]] name = "http" version = "1.1.0" @@ -1210,6 +1216,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "object" version = "0.36.1" @@ -1249,6 +1265,29 @@ dependencies = [ "syn", ] +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + [[package]] name = "paste" version = "1.0.15" @@ -1319,6 +1358,7 @@ dependencies = [ "palette", "rayon", "rgb", + "tokio", ] [[package]] @@ -1536,6 +1576,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "redox_syscall" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "regex" version = "1.10.5" @@ -1678,6 +1727,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + [[package]] name = "simd-adler32" version = "0.3.7" @@ -1830,9 +1888,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" dependencies = [ "backtrace", + "bytes", "libc", "mio", + "num_cpus", + "parking_lot", "pin-project-lite", + "signal-hook-registry", "socket2", "tokio-macros", "windows-sys 0.48.0", diff --git a/Cargo.toml b/Cargo.toml index d6c7840..45cdc67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,3 +20,4 @@ num-traits = "0.2.19" palette = "0.7.6" rayon = "1.10.0" rgb = "0.8.40" +tokio = { version = "1.38.1", features = ["full"] } diff --git a/src/api.rs b/src/api.rs new file mode 100644 index 0000000..b61f66e --- /dev/null +++ b/src/api.rs @@ -0,0 +1,7 @@ +use axum::{Router}; + + +/// API routes for axum +/// Start with the basics: Send an image, crop it, dither, and upload. +/// we defer the upload to a separate task. + diff --git a/src/main.rs b/src/main.rs index 0800518..79d666c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ #[cfg(feature = "eink")] pub mod display; pub mod imageproc; +pub mod api; use crate::display::Wrapper; use crate::imageproc::{DiffusionMatrix, Ditherer, EInkImage, ErrorDiffusionDither}; @@ -25,7 +26,8 @@ enum Command { Serve, } -fn main() -> anyhow::Result<()> { +#[tokio::main] +async fn main() -> anyhow::Result<()> { let cli = Cli::parse(); println!("CLI {cli:?}");