summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRomeo Disca <romeo.disca@gmail.com>2020-08-18 06:40:46 +0200
committerRomeo Disca <romeo.disca@gmail.com>2020-08-18 06:40:46 +0200
commita14cc3f38b67e6054bdbff8aff7c60967f342194 (patch)
treedab55097ece8372c757726a3a81c674710b80894 /src
parentbfc63947702ffb3ca1dca6e8184f0998fb98ed13 (diff)
refactor: change crate to lib
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs9
-rw-r--r--src/main.rs43
2 files changed, 9 insertions, 43 deletions
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..ba9a5f6
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,9 @@
+
+mod enums;
+mod events;
+mod commands;
+mod client;
+
+pub use client::*;
+pub use commands::Command;
+pub use events::Event; \ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
deleted file mode 100644
index dd068fe..0000000
--- a/src/main.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-
-mod enums;
-mod events;
-mod commands;
-mod client;
-
-use std::error::Error;
-use std::time::Duration;
-use std::sync::Arc;
-
-use client::*;
-use commands::Command;
-
-#[tokio::main]
-async fn main() -> Result<(), Box<dyn Error>> {
-
- let event = event_handler(|event| { println!("ping response: {:?}", event); });
- let event2 = event_handler(|event| { println!("ping response: {:?}", event); });
-
- let client = FlicClient::new("127.0.0.1:5551").await?
- .register_event_handler(event).await
- .register_event_handler(event2).await
- ;
- let client1 = Arc::new(client);
- let client2 = client1.clone();
-
- let cmd = tokio::spawn(async move {
- client1.submit(Command::GetInfo).await;
- tokio::time::delay_for(Duration::from_secs(3)).await;
- client1.submit(Command::GetInfo).await;
- tokio::time::delay_for(Duration::from_secs(3)).await;
- client1.stop().await;
- });
- let lst = tokio::spawn(async move {
- client2.listen().await;
- println!("stop");
- });
-
- lst.await?;
- cmd.await?;
-
- Ok(())
-}