✨Minor refractor
This commit is contained in:
parent
a072d495b7
commit
ffcb1e5972
22
src/lib.rs
22
src/lib.rs
|
@ -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();
|
||||
}
|
19
src/main.rs
19
src/main.rs
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue