1#![allow(dead_code)]
3use async_trait::async_trait;
4
5pub mod types {
6 use serde::{Deserialize, Serialize};
7 include!(concat!(env!("OUT_DIR"), "/candela.rs"));
8}
9
10mod error;
11#[cfg(any(feature = "zmq-client", feature = "zmq-server"))]
12mod sockets;
13mod strip;
14
15pub type Error = error::CandelaError;
16pub type Result<T> = std::result::Result<T, error::CandelaError>;
17
18pub use strip::CandelaStrip;
19
20pub type Pixel = [u8; 4];
26
27pub trait CandelaConfig {
28 fn get_ips(&self) -> Vec<[u8; 4]>;
29 fn get_subnet(&self) -> [u8; 4];
30 fn get_netmask(&self) -> [u8; 4];
31 fn get_setup_port(&self) -> u16;
32}
33
34pub trait CandelaServerConfig: CandelaConfig {}
35
36pub trait CandelaClientConfig: CandelaConfig {
37 fn get_name(&self) -> String;
38 fn get_strip_configs(&self) -> Vec<types::LedStripConfig>;
39}
40
41#[async_trait]
43pub trait CandelaServer: std::fmt::Debug {
44 type Controller: CandelaController;
45 fn new<T: CandelaServerConfig>(config: T) -> Result<Self>
46 where
47 Self: Sized;
48 async fn search() -> Vec<types::LedControllerConfig>;
49 async fn connect(config: types::LedControllerConfig) -> Result<()>;
50 fn get_controllers(&mut self) -> &mut Vec<Self::Controller>;
51}
52
53pub trait CandelaController {
57 fn get_strips(&mut self) -> &mut Vec<CandelaStrip>;
58}
59
60#[async_trait]
61pub trait CandelaClient {
62 fn new<T: CandelaClientConfig>(config: T) -> Result<Self>
63 where
64 Self: Sized;
65 async fn setup(&mut self) -> Result<()>;
66 async fn recv(&mut self) -> Result<types::ClientMessage>;
67}