diff --git a/src/api.rs b/src/api.rs index a572edf..819be09 100644 --- a/src/api.rs +++ b/src/api.rs @@ -22,12 +22,12 @@ pub enum ApiError { } #[derive(Clone)] -pub struct Context { +pub struct AppState { display_channel: Sender, display_task: Arc>, } -impl Context { +impl AppState { #[must_use] pub fn new(disp: Box) -> Self { let (tx, rx) = mpsc::channel(2); @@ -86,7 +86,7 @@ pub async fn display_task( /// 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 { +pub fn router() -> Router { Router::new() .route("/setimage", post(set_image)) .route("/preview", post(preview_image)) @@ -149,7 +149,7 @@ where #[instrument(skip(ctx))] async fn set_image( - State(ctx): State, + State(ctx): State, img_req: ImageRequest, ) -> Result { // FIXME: resize image to 800x480 to match the eink panel. diff --git a/src/main.rs b/src/main.rs index e02d2d2..f2d5c73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -80,7 +80,7 @@ async fn main() -> anyhow::Result<()> { Command::Serve => { let display = FakeEInk {}; - let ctx = api::Context::new(Box::new(display)); + let ctx = api::AppState::new(Box::new(display)); let app = api::router().with_state(ctx); let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await?;