use std::collections::BTreeMap;
use std::sync::Arc;
use rmpv::Value;
use crate::client::{ClientError, PluginIpcClient};
#[derive(Clone)]
pub struct CloudClient {
pub(super) ipc: Arc<PluginIpcClient>,
}
impl CloudClient {
pub async fn publish(&self, stream: &str, payload: &[u8]) -> Result<Value, ClientError> {
self.ipc.cloud_publish(stream, payload).await
}
pub async fn put_record(
&self,
collection: &str,
key: &str,
data: Value,
device_id: Option<&str>,
) -> Result<Value, ClientError> {
self.ipc
.cloud_records_put(collection, key, data, device_id)
.await
}
}
#[derive(Clone)]
pub struct NodeClient {
pub(super) ipc: Arc<PluginIpcClient>,
}
impl NodeClient {
pub async fn info(&self) -> Result<ados_protocol::node_info::NodeInfo, ClientError> {
self.ipc.node_info().await
}
}
#[derive(Clone)]
pub struct MdnsClient {
pub(super) ipc: Arc<PluginIpcClient>,
}
impl MdnsClient {
pub async fn advertise(
&self,
service_type: &str,
port: u16,
txt: &BTreeMap<String, String>,
) -> Result<ados_protocol::plugin_mdns::Advertised, ClientError> {
self.ipc.mdns_advertise(service_type, port, txt).await
}
pub async fn browse(
&self,
service_type: &str,
window: std::time::Duration,
) -> Result<Vec<ados_protocol::plugin_mdns::DiscoveredService>, ClientError> {
self.ipc.mdns_browse(service_type, window).await
}
}