Move send_data to new struct Mouth
This commit is contained in:
parent
842337b22b
commit
b52ebc5739
2 changed files with 21 additions and 6 deletions
14
src/main.rs
14
src/main.rs
|
@ -2,14 +2,20 @@ mod api_client;
|
|||
use api_client::ApiClient;
|
||||
mod ear;
|
||||
use ear::Ear;
|
||||
mod mouth;
|
||||
use mouth::Mouth;
|
||||
use serde_json::Value;
|
||||
|
||||
fn main() {
|
||||
let listener = Ear::new();
|
||||
let sender = Mouth::new();
|
||||
|
||||
let url = listener.receive_request();
|
||||
let req: String = parse_url(&url); // TODO: update type
|
||||
let data: String = get_data(&req); // TODO: update type
|
||||
let json_data = transform_to_json(&data);
|
||||
send_data(json_data);
|
||||
|
||||
sender.send_data(json_data);
|
||||
}
|
||||
|
||||
fn parse_url<T>(url: &str) -> T {
|
||||
|
@ -25,10 +31,6 @@ fn get_data<T, R>(request_data: T) -> R {
|
|||
todo!();
|
||||
}
|
||||
|
||||
fn transform_to_json<R>(data: R) -> serde_json::Value {
|
||||
todo!();
|
||||
}
|
||||
|
||||
fn send_data(data: serde_json::Value) {
|
||||
fn transform_to_json<R>(data: R) -> Value {
|
||||
todo!();
|
||||
}
|
||||
|
|
13
src/mouth.rs
Normal file
13
src/mouth.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
use serde_json::Value;
|
||||
|
||||
pub struct Mouth {}
|
||||
|
||||
impl Mouth {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
|
||||
pub fn send_data(&self, data: Value) {
|
||||
todo!();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue