use crate::error::ZmqError;
use crate::message::Msg;
use crate::socket::MonitorSender;
#[cfg(feature = "io-uring")]
use crate::Blob;
#[cfg(feature = "io-uring")]
use std::os::unix::io::RawFd;
use fibre::mpmc::{AsyncReceiver, AsyncSender};
use fibre::oneshot;
#[derive(Debug)]
#[allow(dead_code)]
pub enum Command {
UserBind {
endpoint: String, reply_tx: oneshot::Sender<Result<(), ZmqError>>, },
UserConnect {
endpoint: String, reply_tx: oneshot::Sender<Result<(), ZmqError>>, },
UserDisconnect {
endpoint: String, reply_tx: oneshot::Sender<Result<(), ZmqError>>, },
UserUnbind {
endpoint: String, reply_tx: oneshot::Sender<Result<(), ZmqError>>, },
UserSend {
msg: Msg, },
UserRecv {
reply_tx: oneshot::Sender<Result<Msg, ZmqError>>, },
UserSetOpt {
option: i32, value: Vec<u8>, reply_tx: oneshot::Sender<Result<(), ZmqError>>, },
UserGetOpt {
option: i32, reply_tx: oneshot::Sender<Result<Vec<u8>, ZmqError>>, },
UserMonitor {
monitor_tx: MonitorSender, reply_tx: oneshot::Sender<Result<(), ZmqError>>, },
UserClose {
reply_tx: oneshot::Sender<Result<(), ZmqError>>,
},
Stop,
PipeMessageReceived {
pipe_id: usize,
msg: Msg, },
PipeClosedByPeer {
pipe_id: usize,
},
AttachPipe {
rx_from_core: AsyncReceiver<Msg>,
tx_to_core: AsyncSender<Msg>,
pipe_read_id: usize,
pipe_write_id: usize,
},
ScaInitializePipes {
sca_handle_id: usize,
rx_from_core: AsyncReceiver<Vec<Msg>>,
core_pipe_read_id_for_incoming_routing: usize,
},
#[cfg(feature = "io-uring")]
UringFdMessage { fd: RawFd, msg: Msg },
#[cfg(feature = "io-uring")]
UringFdError { fd: RawFd, error: ZmqError },
#[cfg(feature = "io-uring")]
UringFdHandshakeComplete {
fd: RawFd,
peer_identity: Option<Blob>,
},
}
impl Command {
pub fn variant_name(&self) -> &'static str {
match self {
Command::UserBind { .. } => "UserBind",
Command::UserConnect { .. } => "UserConnect",
Command::UserDisconnect { .. } => "UserDisconnect",
Command::UserUnbind { .. } => "UserUnbind",
Command::UserSend { .. } => "UserSend",
Command::UserRecv { .. } => "UserRecv",
Command::UserSetOpt { .. } => "UserSetOpt",
Command::UserGetOpt { .. } => "UserGetOpt",
Command::UserMonitor { .. } => "UserMonitor",
Command::UserClose { .. } => "UserClose",
Command::Stop => "Stop",
Command::PipeMessageReceived { .. } => "PipeMessageReceived",
Command::PipeClosedByPeer { .. } => "PipeClosedByPeer",
Command::AttachPipe { .. } => "AttachPipe",
Command::ScaInitializePipes { .. } => "ScaInitializePipes",
#[cfg(feature = "io-uring")]
Command::UringFdMessage { .. } => "UringFdMessage",
#[cfg(feature = "io-uring")]
Command::UringFdError { .. } => "UringFdError",
#[cfg(feature = "io-uring")]
Command::UringFdHandshakeComplete { .. } => "UringFdHandshakeComplete",
}
}
}