#![allow(dead_code)]
#![allow(unused)]
pub use alink::aiot_module::{AiotModule, ModuleRecvKind};
pub use alink::ThreeTuple;
pub use dm::{DataModelMsg, DataModelOptions};
pub use dynregmq::{DynamicRegister, DynamicRegisterResult};
pub use http_downloader::HttpDownloader;
pub use https::Http;
pub use mqtt::{DeviceAuthInfo, MqttClient, MqttConnection, MqttInstance};
pub use ra::base::SecureTunnelNotify;
pub use tunnel::protocol::Service as LocalService;
pub use tunnel::proxy::{TunnelAction, TunnelParams, TunnelProxy};
pub use util::error::{Error, Result};
pub mod alink;
pub mod bootstrap;
pub mod dm;
pub mod dynregmq;
pub mod file;
pub mod http_downloader;
pub mod https;
pub mod logpost;
pub mod mqtt;
pub mod ntp;
pub mod ota;
pub mod ra;
pub mod remote_config;
pub mod shadow;
pub mod subdev;
pub mod tag;
pub mod tunnel;
pub mod util;
#[async_trait::async_trait]
pub trait Executor {
async fn execute(&mut self, topic: &str, payload: &[u8]) -> Result<()>;
}
pub fn execute<RecvKind>(three: &ThreeTuple, topic: &str, payload: &[u8]) -> Result<RecvKind::Recv>
where
RecvKind: ModuleRecvKind,
{
log::debug!("receive: {} {}", topic, String::from_utf8_lossy(payload));
if let Some((kind, caps)) = RecvKind::match_kind(topic, &three.product_key, &three.device_name)
{
kind.to_payload(payload, &caps)
} else {
Err(Error::TopicNotMatch(format!("{:?}", RecvKind::show())))
}
}