From a69fa1eb90323c21134551f44c3cea79caa4c99a Mon Sep 17 00:00:00 2001 From: "flyingscorpio@clevo" Date: Thu, 8 Dec 2022 14:21:07 +0100 Subject: [PATCH] Add lib.rs file --- src/lib.rs | 35 +++++++++++++++++++++++++++++++++++ src/main.rs | 33 +-------------------------------- 2 files changed, 36 insertions(+), 32 deletions(-) create mode 100644 src/lib.rs diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..8fede4b --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,35 @@ +#![allow(unused)] + +use serde_json::Value; +mod api_client; +use api_client::ApiClient; +mod ear; +use ear::Ear; +mod mouth; +use mouth::Mouth; + +pub fn run() { + let listener = Ear::new(); + + let (stream, req) = listener.listen(); + let mut sender = Mouth::new(stream); + // let data: String = get_data(&req); // TODO: update type + // let json_data = transform_to_json(&data); + let json_data = serde_json::json!({"test": 200, "foo": "bar"}); + + sender.send_data(json_data); +} + + +fn get_data(request_data: T) -> R { + let api_client = ApiClient::new(); + + let res = api_client.get_ip("8.8.8.8"); + println!("{:#?}", res); + + todo!(); +} + +fn transform_to_json(data: R) -> Value { + todo!(); +} diff --git a/src/main.rs b/src/main.rs index 5e16f8f..cff1b90 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,34 +1,3 @@ -#![allow(unused)] - -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 (stream, req) = listener.listen(); - let mut sender = Mouth::new(stream); - // let data: String = get_data(&req); // TODO: update type - // let json_data = transform_to_json(&data); - let json_data = serde_json::json!({"test": 200, "foo": "bar"}); - - sender.send_data(json_data); -} - -fn get_data(request_data: T) -> R { - let api_client = ApiClient::new(); - - let res = api_client.get_ip("8.8.8.8"); - println!("{:#?}", res); - - todo!(); -} - -fn transform_to_json(data: R) -> Value { - todo!(); + hephaistos::run(); }