Add lib.rs file
This commit is contained in:
parent
9f934c40ae
commit
a69fa1eb90
2 changed files with 36 additions and 32 deletions
35
src/lib.rs
Normal file
35
src/lib.rs
Normal file
|
@ -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<T, R>(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<R>(data: R) -> Value {
|
||||
todo!();
|
||||
}
|
33
src/main.rs
33
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<T, R>(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<R>(data: R) -> Value {
|
||||
todo!();
|
||||
hephaistos::run();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue