mod eip;
use crate::{
cip::{
connection::{ForwardCloseReply, ForwardCloseRequest, ForwardOpenReply, OpenOptions},
service::request::UnconnectedSend,
MessageRequest,
},
Result,
};
use rseip_cip::MessageReplyInterface;
use rseip_core::codec::{Decode, Encode};
#[async_trait::async_trait]
pub trait Service: Send + Sync {
fn is_open(&self) -> bool;
async fn open(&mut self) -> Result<()>;
async fn close(&mut self) -> Result<()>;
async fn heartbeat(&mut self) -> Result<()> {
Ok(())
}
async fn unconnected_send<'de, CP, P, D, R>(
&mut self,
request: UnconnectedSend<CP, MessageRequest<P, D>>,
) -> Result<R>
where
CP: Encode + Send + Sync,
P: Encode + Send + Sync,
D: Encode + Send + Sync,
R: MessageReplyInterface + Decode<'de> + 'static;
async fn connected_send<'de, P, D, R>(
&mut self,
connection_id: u32,
sequence_number: u16,
request: MessageRequest<P, D>,
) -> Result<R>
where
P: Encode + Send + Sync,
D: Encode + Send + Sync,
R: MessageReplyInterface + Decode<'de> + 'static;
async fn forward_open<P>(&mut self, request: OpenOptions<P>) -> Result<ForwardOpenReply>
where
P: Encode + Send + Sync;
async fn forward_close<P>(
&mut self,
request: ForwardCloseRequest<P>,
) -> Result<ForwardCloseReply>
where
P: Encode + Send + Sync;
}