use std::marker::PhantomData;
use crate::uni::{GenericUni, MessagingMutinyStream, channel::{ChannelZeroCopy, ChannelMove}, Uni};
pub type ZeroCopySocketServer<const CONFIG: usize,
const PROCESSOR_UNI_INSTRUMENTS: usize,
const PROCESSOR_BUFFER_SIZE: usize,
const SENDER_BUFFER_SIZE: usize,
RemoteMessages,
LocalMessages >
= SocketServer<CONFIG,
PROCESSOR_UNI_INSTRUMENTS,
PROCESSOR_BUFFER_SIZE,
RemoteMessages,
LocalMessages,
Uni<PROCESSOR_UNI_INSTRUMENTS,
PROCESSOR_BUFFER_SIZE,
RemoteMessages,
ChannelZeroCopy<PROCESSOR_BUFFER_SIZE, RemoteMessages>>,
ChannelZeroCopy<SENDER_BUFFER_SIZE, LocalMessages>>;
pub type MovableSocketServer<const CONFIG: usize,
const PROCESSOR_UNI_INSTRUMENTS: usize,
const PROCESSOR_BUFFER_SIZE: usize,
const SENDER_BUFFER_SIZE: usize,
RemoteMessages,
LocalMessages >
= SocketServer<CONFIG,
PROCESSOR_UNI_INSTRUMENTS,
PROCESSOR_BUFFER_SIZE,
RemoteMessages,
LocalMessages,
Uni<PROCESSOR_UNI_INSTRUMENTS,
PROCESSOR_BUFFER_SIZE,
RemoteMessages,
ChannelMove<PROCESSOR_BUFFER_SIZE, RemoteMessages>>,
ChannelMove<SENDER_BUFFER_SIZE, LocalMessages>>;
pub struct SocketServer<const CONFIG: usize,
const PROCESSOR_UNI_INSTRUMENTS: usize,
const PROCESSOR_BUFFER_SIZE: usize,
RemoteMessages,
LocalMessages,
ProcessorUniType: GenericUni<PROCESSOR_UNI_INSTRUMENTS, PROCESSOR_BUFFER_SIZE>,
SenderChannelType> {
pub _phantom: PhantomData<(RemoteMessages,LocalMessages,ProcessorUniType,SenderChannelType)>
}
impl<const CONFIG: usize,
const PROCESSOR_UNI_INSTRUMENTS: usize,
const PROCESSOR_BUFFER_SIZE: usize,
RemoteMessages,
LocalMessages,
ProcessorUniType: GenericUni<PROCESSOR_UNI_INSTRUMENTS, PROCESSOR_BUFFER_SIZE>,
SenderChannelType>
SocketServer<CONFIG, PROCESSOR_UNI_INSTRUMENTS, PROCESSOR_BUFFER_SIZE, RemoteMessages, LocalMessages, ProcessorUniType, SenderChannelType> {
pub fn start<LocalMessagesIteratorType: Iterator<Item=LocalMessages>>
(self,
_connection_events_handler: impl FnMut(ConnectionEvents<SenderChannelType>),
_processor: impl FnOnce(MessagingMutinyStream<PROCESSOR_UNI_INSTRUMENTS,
PROCESSOR_BUFFER_SIZE,
ProcessorUniType>)
-> LocalMessagesIteratorType)
-> impl SocketServerController {
self
}
}
pub trait SocketServerController {
fn _shutdown(self);
}
impl<const CONFIG: usize,
const PROCESSOR_UNI_INSTRUMENTS: usize,
const PROCESSOR_BUFFER_SIZE: usize,
RemoteMessages,
LocalMessages,
ProcessorUniType: GenericUni<PROCESSOR_UNI_INSTRUMENTS, PROCESSOR_BUFFER_SIZE>,
SenderChannelType>
SocketServerController for
SocketServer<CONFIG, PROCESSOR_UNI_INSTRUMENTS, PROCESSOR_BUFFER_SIZE, RemoteMessages, LocalMessages, ProcessorUniType, SenderChannelType> {
fn _shutdown(self) {}
}
pub trait GenericSocketServer<const PROCESSOR_UNI_INSTRUMENTS: usize,
const PROCESSOR_BUFFER_SIZE: usize> {
const CONFIG: usize;
type RemoteMessages;
type LocalMessages;
type ProcessorUniType: GenericUni<PROCESSOR_UNI_INSTRUMENTS, PROCESSOR_BUFFER_SIZE>;
type SenderChannelType;
type ConnectionEventType;
type StreamItemType;
type StreamType;
}
impl<const CONFIG: usize,
const PROCESSOR_UNI_INSTRUMENTS: usize,
const PROCESSOR_BUFFER_SIZE: usize,
RemoteMessages,
LocalMessages,
ProcessorUniType: GenericUni<PROCESSOR_UNI_INSTRUMENTS, PROCESSOR_BUFFER_SIZE>,
SenderChannelType>
GenericSocketServer<PROCESSOR_UNI_INSTRUMENTS,
PROCESSOR_BUFFER_SIZE> for
SocketServer<CONFIG,
PROCESSOR_UNI_INSTRUMENTS,
PROCESSOR_BUFFER_SIZE,
RemoteMessages,
LocalMessages,
ProcessorUniType,
SenderChannelType> {
const CONFIG: usize = CONFIG;
type RemoteMessages = RemoteMessages;
type LocalMessages = LocalMessages;
type ProcessorUniType = ProcessorUniType;
type SenderChannelType = SenderChannelType;
type ConnectionEventType = SenderChannelType;
type StreamItemType = ProcessorUniType::DerivedItemType;
type StreamType = MessagingMutinyStream<PROCESSOR_UNI_INSTRUMENTS,
PROCESSOR_BUFFER_SIZE,
ProcessorUniType>;
}
pub enum ConnectionEvents<SenderChannelType> {
_Connected(SenderChannelType),
_Disconnected(SenderChannelType),
_IOError(SenderChannelType),
}