added serde for serializing in the webserver

This commit is contained in:
Djeeberjr 2025-08-15 16:46:44 +02:00
parent fabb14de86
commit 21480cef4f
5 changed files with 11 additions and 10 deletions

1
Cargo.lock generated
View File

@ -1062,6 +1062,7 @@ dependencies = [
"heapless", "heapless",
"log", "log",
"picoserve", "picoserve",
"serde",
"smart-leds", "smart-leds",
"smoltcp", "smoltcp",
"static_cell", "static_cell",

View File

@ -60,15 +60,13 @@ edge-nal = "0.5.0"
edge-nal-embassy = { version = "0.6.0", features = ["log"] } edge-nal-embassy = { version = "0.6.0", features = ["log"] }
picoserve = { version = "0.16.0", features = ["embassy", "log"] } picoserve = { version = "0.16.0", features = ["embassy", "log"] }
embassy-sync = { version = "0.7.0", features = ["log"] } embassy-sync = { version = "0.7.0", features = ["log"] }
ds3231 = { version = "0.3.0", features = ["async", "temperature_f32"] } ds3231 = { version = "0.3.0", features = ["async", "temperature_f32"] }
chrono = { version = "0.4.41", default-features = false } chrono = { version = "0.4.41", default-features = false }
dir-embed = "0.3.0" dir-embed = "0.3.0"
embedded-sdmmc-dev = "0.8.2" embedded-sdmmc-dev = "0.8.2"
esp-hal-smartled = { git = "https://github.com/esp-rs/esp-hal-community.git", package = "esp-hal-smartled", branch = "main", features = ["esp32c6"]} esp-hal-smartled = { git = "https://github.com/esp-rs/esp-hal-community.git", package = "esp-hal-smartled", branch = "main", features = ["esp32c6"]}
smart-leds = "0.4.0" smart-leds = "0.4.0"
serde = { version = "1.0.219", default-features = false, features = ["derive", "alloc"] }
[profile.dev] [profile.dev]
# Rust debug is too slow. # Rust debug is too slow.

View File

@ -17,6 +17,8 @@ use static_cell::make_static;
use crate::{store::TallyID, webserver::start_webserver}; use crate::{store::TallyID, webserver::start_webserver};
extern crate alloc;
mod drivers; mod drivers;
mod feedback; mod feedback;
mod init; mod init;

View File

@ -1,14 +1,15 @@
extern crate alloc;
use super::TallyID; use super::TallyID;
use alloc::collections::BTreeMap; use alloc::collections::BTreeMap;
use alloc::string::String; use alloc::string::String;
use serde::Serialize;
#[derive(Clone, Serialize)]
pub struct Name { pub struct Name {
pub first: String, pub first: String,
pub last: String, pub last: String,
} }
#[derive(Clone, Serialize)]
pub struct IDMapping { pub struct IDMapping {
id_map: BTreeMap<TallyID, Name>, id_map: BTreeMap<TallyID, Name>,
} }
@ -28,4 +29,3 @@ impl IDMapping {
self.id_map.insert(id, name); self.id_map.insert(id, name);
} }
} }

View File

@ -1,11 +1,10 @@
extern crate alloc;
use super::Date; use super::Date;
use super::IDMapping; use super::IDMapping;
use super::TallyID; use super::TallyID;
use alloc::collections::BTreeMap; use alloc::collections::BTreeMap;
use alloc::vec::Vec; use alloc::vec::Vec;
#[derive(Clone)]
pub struct AttendanceDay { pub struct AttendanceDay {
date: Date, date: Date,
ids: Vec<TallyID>, ids: Vec<TallyID>,
@ -30,9 +29,10 @@ impl AttendanceDay {
} }
} }
#[derive(Clone)]
pub struct IDStore { pub struct IDStore {
days: BTreeMap<Date, AttendanceDay>, pub days: BTreeMap<Date, AttendanceDay>,
mapping: IDMapping, pub mapping: IDMapping,
} }
impl IDStore { impl IDStore {