Compare commits
8 Commits
8c796b1590
...
online
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f44a68e5e8 | ||
|
|
bf531b477f | ||
|
|
6aeb5e1c2a | ||
|
|
ecb51125cc | ||
|
|
d7c5f0f048 | ||
|
|
2a89528b8f | ||
|
|
1957ff7f9f | ||
|
|
2e84b06a91 |
1
POC_in_rust/.gitignore
vendored
Normal file
1
POC_in_rust/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
target
|
||||||
@@ -3,12 +3,19 @@ name = "POC_in_rust"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
opt-level="s"
|
||||||
|
lto="fat"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
async-tungstenite = {version="0.29.1", features=["tokio-rustls-webpki-roots"]}
|
||||||
|
chrono = "0.4.41"
|
||||||
env_logger = "0.11.8"
|
env_logger = "0.11.8"
|
||||||
futures-lite = "2.6.0"
|
iced = {"git"= "https://github.com/iced-rs/iced.git", "features"=["tokio", "auto-detect-theme", "fira-sans", "tiny-skia", "sipper"]}
|
||||||
iced = {"git"= "https://github.com/iced-rs/iced.git", "features"=["tokio", "auto-detect-theme", "fira-sans", "tiny-skia", "wgpu", "sipper"]}
|
|
||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
nusb = "0.1.13"
|
nusb = "0.1.13"
|
||||||
|
reqwest = { version = "0.12.15", features = ["json"] }
|
||||||
|
rustls = {version = "0.23.27", features = ["std", "prefer-post-quantum", "tls12", "logging"]}
|
||||||
serde = {version = "1.0.219", features=["derive"]}
|
serde = {version = "1.0.219", features=["derive"]}
|
||||||
serde_json = "1.0.140"
|
serde_json = "1.0.140"
|
||||||
tokio = {version = "1.45.0", features=["time", "fs", "io-util", "macros"]}
|
tokio = {version = "1.45.0", features=["time", "fs", "io-util", "macros"]}
|
||||||
|
|||||||
5
POC_in_rust/config.json
Normal file
5
POC_in_rust/config.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"DURATION": 600,
|
||||||
|
"STATION_ID": 2,
|
||||||
|
"HOST": "https://beta.alkator.cz"
|
||||||
|
}
|
||||||
102
POC_in_rust/people.json
Normal file
102
POC_in_rust/people.json
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
{
|
||||||
|
"1": 1114418469,
|
||||||
|
"2": 1111554085,
|
||||||
|
"3": 1112605381,
|
||||||
|
"4": 1362080126,
|
||||||
|
"5": 1632101230,
|
||||||
|
"6": 1114533941,
|
||||||
|
"7": 1364901054,
|
||||||
|
"8": 1364587710,
|
||||||
|
"9": 1364867822,
|
||||||
|
"10": 1364554558,
|
||||||
|
"11": 1364968750,
|
||||||
|
"12": 1111614357,
|
||||||
|
"13": 1362569198,
|
||||||
|
"14": 1364867662,
|
||||||
|
"15": 1112618821,
|
||||||
|
"16": 1364967150,
|
||||||
|
"17": 1364592718,
|
||||||
|
"18": 1364487310,
|
||||||
|
"19": 458336708,
|
||||||
|
"20": 1111590293,
|
||||||
|
"21": 1114448773,
|
||||||
|
"22": 1364550814,
|
||||||
|
"23": 1112421509,
|
||||||
|
"24": 1364529422,
|
||||||
|
"25": 1364916590,
|
||||||
|
"26": 455988804,
|
||||||
|
"27": 1631963022,
|
||||||
|
"28": 1114508533,
|
||||||
|
"29": 1364590606,
|
||||||
|
"30": 1364796894,
|
||||||
|
"31": 1112489029,
|
||||||
|
"32": 1114588261,
|
||||||
|
"33": 1111733589,
|
||||||
|
"34": 1112469509,
|
||||||
|
"35": 1632521678,
|
||||||
|
"36": 1631957710,
|
||||||
|
"37": 1111682853,
|
||||||
|
"38": 1111882197,
|
||||||
|
"39": 1631960974,
|
||||||
|
"40": 1362260606,
|
||||||
|
"41": 1364521806,
|
||||||
|
"42": 1364489406,
|
||||||
|
"43": 1361969902,
|
||||||
|
"44": 1364581838,
|
||||||
|
"45": 1364520526,
|
||||||
|
"46": 1361806574,
|
||||||
|
"47": 1364581310,
|
||||||
|
"48": 1364551150,
|
||||||
|
"49": 1364916158,
|
||||||
|
"50": 1364529662,
|
||||||
|
"51": 1632026766,
|
||||||
|
"52": 1364588798,
|
||||||
|
"53": 1631955550,
|
||||||
|
"54": 1631972606,
|
||||||
|
"55": 1364797086,
|
||||||
|
"56": 1364627198,
|
||||||
|
"57": 1364556446,
|
||||||
|
"58": 1632070414,
|
||||||
|
"59": 1631951758,
|
||||||
|
"60": 1364794654,
|
||||||
|
"61": 1632101166,
|
||||||
|
"62": 1361810574,
|
||||||
|
"63": 1114573589,
|
||||||
|
"64": 1361967886,
|
||||||
|
"65": 1632544222,
|
||||||
|
"66": 1111582085,
|
||||||
|
"67": 1362569438,
|
||||||
|
"68": 1364593198,
|
||||||
|
"69": 1364761406,
|
||||||
|
"70": 1631927918,
|
||||||
|
"71": 1364544414,
|
||||||
|
"72": 1362264958,
|
||||||
|
"73": 1364767006,
|
||||||
|
"74": 1364590110,
|
||||||
|
"75": 1362082334,
|
||||||
|
"76": 1364799166,
|
||||||
|
"77": 1632028398,
|
||||||
|
"78": 1361970078,
|
||||||
|
"79": 1364485118,
|
||||||
|
"80": 1364490846,
|
||||||
|
"81": 1632150846,
|
||||||
|
"82": 1362569342,
|
||||||
|
"83": 1362599998,
|
||||||
|
"84": 1632523854,
|
||||||
|
"85": 1364765134,
|
||||||
|
"86": 1631952062,
|
||||||
|
"87": 1364559822,
|
||||||
|
"88": 1364783854,
|
||||||
|
"89": 1362081950,
|
||||||
|
"90": 1111644021,
|
||||||
|
"91": 1631959326,
|
||||||
|
"92": 1364901422,
|
||||||
|
"93": 1632100830,
|
||||||
|
"94": 1111707429,
|
||||||
|
"95": 1632026702,
|
||||||
|
"96": 1362569022,
|
||||||
|
"97": 1114560181,
|
||||||
|
"98": 1364588510,
|
||||||
|
"99": 1364785486,
|
||||||
|
"100": 1361969950
|
||||||
|
}
|
||||||
25
POC_in_rust/src/approx_time.rs
Normal file
25
POC_in_rust/src/approx_time.rs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
use std::time::{Instant, SystemTime};
|
||||||
|
use serde::{Serialize, Serializer, Deserialize, Deserializer, de::Error};
|
||||||
|
|
||||||
|
pub fn serialize<S>(instant: &Instant, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
|
let system_now = SystemTime::now();
|
||||||
|
let instant_now = Instant::now();
|
||||||
|
let approx = system_now - (instant_now - *instant);
|
||||||
|
approx.serialize(serializer)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn deserialize<'de, D>(deserializer: D) -> Result<Instant, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
let de = SystemTime::deserialize(deserializer)?;
|
||||||
|
let system_now = SystemTime::now();
|
||||||
|
let instant_now = Instant::now();
|
||||||
|
let duration = system_now.duration_since(de).map_err(Error::custom)?;
|
||||||
|
let approx = instant_now - duration;
|
||||||
|
Ok(approx)
|
||||||
|
}
|
||||||
66
POC_in_rust/src/card_reader.rs
Normal file
66
POC_in_rust/src/card_reader.rs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
use iced::task::{Never, Sipper, sipper};
|
||||||
|
use tokio::time::sleep;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use nusb::{transfer::{ RequestBuffer, TransferError }, Interface};
|
||||||
|
|
||||||
|
static USB_VENDOR: u16 = 0xffff;
|
||||||
|
static USB_PRODUCT: u16 = 0x0035;
|
||||||
|
|
||||||
|
|
||||||
|
fn get_interface() -> Option<Interface> {
|
||||||
|
let dev = nusb::list_devices().ok()?.find(|dev| dev.vendor_id() == USB_VENDOR && dev.product_id() == USB_PRODUCT)?;
|
||||||
|
let device = dev.open().ok()?;
|
||||||
|
device.detach_and_claim_interface(0).ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn connect() -> impl Sipper<Never, Event> {
|
||||||
|
sipper(async |mut output|{
|
||||||
|
loop {
|
||||||
|
let interface = loop {
|
||||||
|
if let Some(interface) = get_interface(){
|
||||||
|
break interface;
|
||||||
|
}
|
||||||
|
sleep(Duration::new(0, 100)).await;
|
||||||
|
};
|
||||||
|
output.send(Event::Connected).await;
|
||||||
|
let mut card_id = 0;
|
||||||
|
loop {
|
||||||
|
let buf = RequestBuffer::new(8);
|
||||||
|
let data = interface.interrupt_in(0x81, buf).await;
|
||||||
|
match data.status {
|
||||||
|
Err(TransferError::Disconnected) => {
|
||||||
|
output.send(Event::Disconnected).await;
|
||||||
|
break;
|
||||||
|
},
|
||||||
|
Ok(()) => {
|
||||||
|
let code = data.data[2];
|
||||||
|
match code {
|
||||||
|
40 => {
|
||||||
|
output.send(Event::ReadedCardId(card_id)).await;
|
||||||
|
card_id = 0;
|
||||||
|
},
|
||||||
|
0 => (),
|
||||||
|
x @ 30..=38 => {
|
||||||
|
card_id *= 10;
|
||||||
|
card_id += x as usize - 29;
|
||||||
|
},
|
||||||
|
39 => {
|
||||||
|
card_id *= 10;
|
||||||
|
},
|
||||||
|
_ => panic!(),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_ => todo!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum Event{
|
||||||
|
Disconnected,
|
||||||
|
Connected,
|
||||||
|
ReadedCardId(usize),
|
||||||
|
}
|
||||||
30
POC_in_rust/src/config.rs
Normal file
30
POC_in_rust/src/config.rs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
use std::fs::File;
|
||||||
|
use std::io::BufReader;
|
||||||
|
use std::error::Error;
|
||||||
|
use std::path::Path;
|
||||||
|
use serde::{Deserialize};
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct Config {
|
||||||
|
pub DURATION: u64,
|
||||||
|
pub STATION_ID: usize,
|
||||||
|
pub HOST: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_config_from_file<P: AsRef<Path>>(path: P) -> Result<Config, Box<dyn Error>> {
|
||||||
|
// Open the file in read-only mode with buffer.
|
||||||
|
let file = File::open(path)?;
|
||||||
|
let reader = BufReader::new(file);
|
||||||
|
|
||||||
|
// Read the JSON contents of the file as an instance of `User`.
|
||||||
|
let config = serde_json::from_reader(reader)?;
|
||||||
|
|
||||||
|
// Return the `User`.
|
||||||
|
Ok(config)
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub static ref CONFIG: Config = read_config_from_file("config.json").unwrap();
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use iced::time::{self, Duration, Instant, milliseconds, seconds};
|
use iced::time::{self, Duration, Instant, milliseconds};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::{Formatter, Error as fmtError};
|
use std::fmt::{Formatter, Error as fmtError};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -6,6 +6,15 @@ use iced::widget::{center, column, row, text};
|
|||||||
use iced::{Element, Subscription, Theme, Center, Task};
|
use iced::{Element, Subscription, Theme, Center, Task};
|
||||||
use tokio::fs::File;
|
use tokio::fs::File;
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
|
use std::fs::read_to_string;
|
||||||
|
use reqwest::Client;
|
||||||
|
use chrono::{DateTime, Local};
|
||||||
|
use iced::futures::join;
|
||||||
|
use lazy_static::lazy_static;
|
||||||
|
use std::io::BufReader;
|
||||||
|
use std::error::Error;
|
||||||
|
use std::fs::File as stdFile;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
mod card_reader;
|
mod card_reader;
|
||||||
mod approx_time;
|
mod approx_time;
|
||||||
@@ -17,13 +26,37 @@ use config::CONFIG;
|
|||||||
struct RacerTime{
|
struct RacerTime{
|
||||||
#[serde(with = "approx_time")]
|
#[serde(with = "approx_time")]
|
||||||
time: Instant,
|
time: Instant,
|
||||||
racer: Racer,
|
racer: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn invert_hashmap<K, V>(map: HashMap<K, V>) -> HashMap<V, K>
|
||||||
|
where
|
||||||
|
K: Eq + std::hash::Hash,
|
||||||
|
V: Eq + std::hash::Hash,
|
||||||
|
{
|
||||||
|
map.into_iter().map(|(k, v)| (v, k)).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_db_from_file<P: AsRef<Path>>(path: P) -> Result<HashMap<usize, usize>, Box<dyn Error>> {
|
||||||
|
// Open the file in read-only mode with buffer.
|
||||||
|
let file = stdFile::open(path)?;
|
||||||
|
let reader = BufReader::new(file);
|
||||||
|
|
||||||
|
// Read the JSON contents of the file as an instance of `User`.
|
||||||
|
let db = serde_json::from_reader(reader)?;
|
||||||
|
|
||||||
|
// Return the `User`.
|
||||||
|
Ok(db)
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static!{
|
||||||
|
// invert it so it is db[card_id] = starting number
|
||||||
|
pub static ref DB: HashMap<usize, usize> = invert_hashmap(read_db_from_file("people.json").unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
struct State{
|
struct State{
|
||||||
racers: Vec<RacerTime>,
|
racers: Vec<RacerTime>,
|
||||||
db: HashMap<usize, Racer>,
|
|
||||||
#[serde(with = "approx_time")]
|
#[serde(with = "approx_time")]
|
||||||
time: Instant,
|
time: Instant,
|
||||||
}
|
}
|
||||||
@@ -31,8 +64,7 @@ struct State{
|
|||||||
impl Default for State {
|
impl Default for State {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
racers: vec![RacerTime{time: Instant::now(), racer: Racer{starting_number:11,racer_id: 0, card_id: 0}}],
|
racers: vec![],
|
||||||
db: Default::default(),
|
|
||||||
time: Instant::now(),
|
time: Instant::now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,34 +76,64 @@ async fn dump_state(json: String) -> Result<(), tokio::io::Error> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct RegisterRacer{
|
||||||
|
starting_number: usize,
|
||||||
|
time: String,
|
||||||
|
station_id: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Message{
|
||||||
|
CardReader(card_reader::Event),
|
||||||
|
Tick(Instant),
|
||||||
|
Nothing,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Debug for Message {
|
||||||
|
// Required method
|
||||||
|
fn fmt(&self, _f: &mut Formatter<'_>) -> Result<(), fmtError>{
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn station_register(starting_number: usize, time: DateTime::<Local>) -> Result<(), reqwest::Error>{
|
||||||
|
let register_racer = RegisterRacer{
|
||||||
|
starting_number: starting_number,
|
||||||
|
station_id: CONFIG.STATION_ID,
|
||||||
|
time: format!("{}", time.format("%d.%m.%Y %H:%M:%S.%6f")),
|
||||||
|
};
|
||||||
|
Client::new()
|
||||||
|
.post(CONFIG.HOST.clone() + "/api/station/register")
|
||||||
|
.json(®ister_racer)
|
||||||
|
.send()
|
||||||
|
.await?;
|
||||||
|
// Result can be error (400 and so on), whatever for now
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn register_and_dump(card_id: usize, datetime: DateTime<Local>, json: String) -> (Result<(), tokio::io::Error>, Result<(), reqwest::Error>){
|
||||||
|
return join!(dump_state(json), station_register(card_id, datetime))
|
||||||
|
}
|
||||||
|
|
||||||
impl State{
|
impl State{
|
||||||
fn update(&mut self, message: Message) -> Task<Message>{
|
fn update(&mut self, message: Message) -> Task<Message>{
|
||||||
match message {
|
match message {
|
||||||
Message::RacerAdded(racer) => {
|
|
||||||
self.db.insert(racer.card_id, racer);
|
|
||||||
Task::none()
|
|
||||||
},
|
|
||||||
Message::Tick(time) => {
|
Message::Tick(time) => {
|
||||||
if let Some(racer_time) = self.racers.iter().next() {
|
|
||||||
if time - racer_time.time > Duration::new(CONFIG.DURATION + 10, 0){
|
|
||||||
self.racers.remove(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.time = time;
|
self.time = time;
|
||||||
Task::none()
|
Task::none()
|
||||||
},
|
},
|
||||||
Message::DumpState(_) => {
|
|
||||||
let json = serde_json::to_string(self).unwrap();
|
|
||||||
Task::perform(dump_state(json), |_| Message::Nothing)
|
|
||||||
},
|
|
||||||
Message::Nothing => Task::none(),
|
Message::Nothing => Task::none(),
|
||||||
Message::CardReader(card_reader::Event::ReadedCardId(card_id)) => {
|
Message::CardReader(card_reader::Event::ReadedCardId(card_id)) => {
|
||||||
if let Some(racer) = self.db.get(&card_id){
|
let time = Instant::now();
|
||||||
self.racers.push(RacerTime{time: Instant::now(), racer: racer.clone()})
|
let datetime = Local::now();
|
||||||
}else{
|
if let Some(&racer_starting_number) = DB.get(&card_id){
|
||||||
|
let racer_time = RacerTime{time, racer: racer_starting_number};
|
||||||
|
self.racers.push(racer_time);
|
||||||
|
} else {
|
||||||
println!("Racer {} not found in db!", card_id)
|
println!("Racer {} not found in db!", card_id)
|
||||||
};
|
}
|
||||||
Task::none()
|
let json = serde_json::to_string(self).unwrap();
|
||||||
|
Task::perform(register_and_dump(card_id, datetime, json), |_| Message::Nothing)
|
||||||
},
|
},
|
||||||
Message::CardReader(card_reader::Event::Connected) => {
|
Message::CardReader(card_reader::Event::Connected) => {
|
||||||
println!("Card Reader Connected!");
|
println!("Card Reader Connected!");
|
||||||
@@ -100,10 +162,12 @@ impl State{
|
|||||||
} else {
|
} else {
|
||||||
(duration - time, false)
|
(duration - time, false)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let seconds = duration.as_secs();
|
let seconds = duration.as_secs();
|
||||||
|
|
||||||
|
if negative && seconds >= 10 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
let duration = text!(
|
let duration = text!(
|
||||||
"{}{:0>2}:{:0>2}.{:0>2}",
|
"{}{:0>2}:{:0>2}.{:0>2}",
|
||||||
if negative {"-"} else {""},
|
if negative {"-"} else {""},
|
||||||
@@ -113,7 +177,7 @@ impl State{
|
|||||||
).size(20).width(120).align_x(Center).align_y(Center);
|
).size(20).width(120).align_x(Center).align_y(Center);
|
||||||
content = content.push(
|
content = content.push(
|
||||||
row![
|
row![
|
||||||
text(racer_time.racer.starting_number.to_string()).size(20).width(120).align_x(Center).align_y(Center), duration
|
text(racer_time.racer.to_string()).size(20).width(120).align_x(Center).align_y(Center), duration
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -122,7 +186,6 @@ impl State{
|
|||||||
fn subscription(&self) -> Subscription<Message> {
|
fn subscription(&self) -> Subscription<Message> {
|
||||||
Subscription::batch(vec![
|
Subscription::batch(vec![
|
||||||
time::every(milliseconds(10)).map(Message::Tick),
|
time::every(milliseconds(10)).map(Message::Tick),
|
||||||
time::every(seconds(CONFIG.SAVING_INTERVAL)).map(Message::DumpState),
|
|
||||||
Subscription::run(card_reader::connect).map(Message::CardReader),
|
Subscription::run(card_reader::connect).map(Message::CardReader),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
@@ -131,31 +194,11 @@ impl State{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
|
||||||
struct Racer{
|
|
||||||
starting_number: usize,
|
|
||||||
card_id: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum Message{
|
|
||||||
CardReader(card_reader::Event),
|
|
||||||
RacerAdded(Racer),
|
|
||||||
Tick(Instant),
|
|
||||||
DumpState(Instant),
|
|
||||||
Nothing,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Debug for Message {
|
|
||||||
// Required method
|
|
||||||
fn fmt(&self, _f: &mut Formatter<'_>) -> Result<(), fmtError>{
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pub fn main() -> iced::Result {
|
pub fn main() -> iced::Result {
|
||||||
|
let init_state = || -> State {read_to_string("state.json").ok().map(|s| serde_json::from_str(&s).ok()).flatten().unwrap_or_else(||Default::default())} ;
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
iced::application(State::default, State::update, State::view)
|
rustls::crypto::aws_lc_rs::default_provider().install_default().unwrap();
|
||||||
|
iced::application(init_state, State::update, State::view)
|
||||||
.subscription(State::subscription)
|
.subscription(State::subscription)
|
||||||
.theme(State::theme)
|
.theme(State::theme)
|
||||||
.run()
|
.run()
|
||||||
|
|||||||
2
log.json
2
log.json
@@ -1 +1 @@
|
|||||||
[]
|
[{"url": "https://beta.alkator.cz/api/card/register", "json": {"racer_id": 60, "starting_number": 2, "card_id": 1364550814, "time": "10.05.2025 17:40:13.486403"}}, {"url": "https://beta.alkator.cz/api/station/register", "json": {"card_id": 1364550814, "time": "10.05.2025 17:42:45.425016", "station_id": 1}}]
|
||||||
Reference in New Issue
Block a user