Minor refractor

This commit is contained in:
Leonie 2023-12-05 17:44:09 +01:00
parent a072d495b7
commit ffcb1e5972
2 changed files with 21 additions and 20 deletions

View file

@ -1,9 +1,27 @@
use reqwest::Client;
use serde::ser::Serialize;
use tokio;
pub enum Task {
FW,
BW,
OFF,
Speed(f64),
Addr(String),
}
#[derive(Debug, Clone)]
pub enum Message {
Addr(String),
FW,
BW,
Stop,
Speed(f64),
}
#[tokio::main]
pub async fn post<T: Serialize>(addr: &String, form_a: &str, form_b: T) {
let c = Client::new();
let p = [(form_a, form_b)];
c.post(addr).form(&p).send().await;
}
c.post(addr).form(&p).send().await.unwrap();
}

View file

@ -2,7 +2,7 @@ use iced::widget::container;
use iced::widget::Column;
use iced::widget::{button, text_input, Slider};
use iced::{executor, Alignment, Application, Command, Element, Length, Renderer, Settings, Theme};
use kontroller::post;
use kontroller::*;
use std::sync::mpsc;
use std::sync::mpsc::Sender;
use std::thread;
@ -73,23 +73,6 @@ impl Default for State {
}
}
#[derive(Debug, Clone)]
enum Message {
Addr(String),
FW,
BW,
Stop,
Speed(f64),
}
enum Task {
FW,
BW,
OFF,
Speed(f64),
Addr(String),
}
impl Application for State {
type Message = Message;
type Theme = Theme;