From b52ebc5739512a59d5fc37b4258d2e939a10d97d Mon Sep 17 00:00:00 2001 From: "flyingscorpio@clevo" Date: Fri, 2 Dec 2022 21:31:49 +0100 Subject: [PATCH] Move send_data to new struct Mouth --- src/main.rs | 14 ++++++++------ src/mouth.rs | 13 +++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 src/mouth.rs diff --git a/src/main.rs b/src/main.rs index 49c5f61..a06f748 100644 --- a/src/main.rs +++ b/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(url: &str) -> T { @@ -25,10 +31,6 @@ fn get_data(request_data: T) -> R { todo!(); } -fn transform_to_json(data: R) -> serde_json::Value { - todo!(); -} - -fn send_data(data: serde_json::Value) { +fn transform_to_json(data: R) -> Value { todo!(); } diff --git a/src/mouth.rs b/src/mouth.rs new file mode 100644 index 0000000..f11fe23 --- /dev/null +++ b/src/mouth.rs @@ -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!(); + } +}