use tokio::sync::mpsc::Sender;
use crate::primitives::{Broadcast, DeliveryType, Peer, PeerId, StreamType};
use crate::rpc::RpcParam;
pub use chamomile_types::message::{StateRequest, StateResponse};
#[cfg(not(feature = "single"))]
use crate::group::GroupId;
#[derive(Debug)]
pub enum SendType {
Connect(u64, Peer, Vec<u8>),
Result(u64, Peer, bool, bool, Vec<u8>),
Disconnect(PeerId),
Event(u64, PeerId, Vec<u8>),
Stream(u32, StreamType, Vec<u8>),
}
#[derive(Debug)]
pub enum RecvType {
Connect(Peer, Vec<u8>),
Result(Peer, bool, Vec<u8>),
ResultConnect(Peer, Vec<u8>),
Leave(Peer),
Event(PeerId, Vec<u8>),
Stream(u32, StreamType, Vec<u8>),
Delivery(DeliveryType, u64, bool),
}
#[derive(Debug)]
pub enum RpcRecvType {
Connect(u64, PeerId, String),
Leave(u64),
Event(u64, PeerId, RpcParam),
}
#[derive(Debug)]
pub enum RpcSendType {
Connect(String, PeerId, String, String),
Leave(u64),
Event(u64, RpcParam),
}
#[derive(Debug)]
pub enum NetworkType {
Connect(Peer),
DisConnect(Peer),
Broadcast(Broadcast, Vec<u8>),
NetworkState(StateRequest, Sender<StateResponse>),
NetworkReboot,
NetworkStop,
#[cfg(any(feature = "multiple", feature = "full"))]
AddGroup(GroupId),
#[cfg(any(feature = "multiple", feature = "full"))]
DelGroup(GroupId),
}
#[cfg(feature = "std")]
#[derive(Debug)]
pub enum SendMessage {
Own(SendType),
Group(SendType),
Layer(GroupId, SendType),
Rpc(RpcSendType),
Network(NetworkType),
}
#[cfg(feature = "std")]
#[derive(Debug)]
pub enum ReceiveMessage {
Own(RecvType),
Group(RecvType),
Layer(GroupId, GroupId, RecvType),
Rpc(RpcRecvType),
NetworkLost,
}
#[cfg(feature = "single")]
#[derive(Debug)]
pub enum SendMessage {
Own(SendType),
Group(SendType),
Rpc(RpcSendType),
Network(NetworkType),
}
#[cfg(feature = "single")]
#[derive(Debug)]
pub enum ReceiveMessage {
Own(RecvType),
Group(RecvType),
Rpc(RpcRecvType),
NetworkLost,
}
#[cfg(feature = "multiple")]
#[derive(Debug)]
pub enum SendMessage {
Own(SendType),
Group(GroupId, SendType),
Rpc(RpcSendType),
Network(NetworkType),
}
#[cfg(feature = "multiple")]
#[derive(Debug)]
pub enum ReceiveMessage {
Own(RecvType),
Group(GroupId, RecvType),
Rpc(RpcRecvType),
NetworkLost,
}
#[cfg(feature = "full")]
#[derive(Debug)]
pub enum SendMessage {
Own(SendType),
Group(GroupId, SendType),
Layer(GroupId, GroupId, SendType),
Rpc(RpcSendType),
Network(NetworkType),
}
#[cfg(feature = "full")]
#[derive(Debug)]
pub enum ReceiveMessage {
Own(RecvType),
Group(GroupId, RecvType),
Layer(GroupId, GroupId, RecvType),
Rpc(RpcRecvType),
NetworkLost,
}