pub enum ProtocolEvent<const CONFIG: u64, LocalMessages: ReactiveMessagingSerializer<LocalMessages> + Send + Sync + PartialEq + Debug + 'static, SenderChannel: FullDuplexUniChannel<ItemType = LocalMessages, DerivedItemType = LocalMessages> + Send + Sync, StateType: Send + Sync + Clone + Debug + 'static = ()> {
PeerArrived {
peer: Arc<Peer<CONFIG, LocalMessages, SenderChannel, StateType>>,
},
PeerLeft {
peer: Arc<Peer<CONFIG, LocalMessages, SenderChannel, StateType>>,
stream_stats: Arc<dyn StreamExecutorStats + Sync + Send>,
},
LocalServiceTermination,
}
Expand description
Event issued by Composite Protocol Clients & Servers to their Reactive Processors.
The user code may use those events to maintain a list of connected parties, be notified of stop/close/quit requests, init/de-init sessions, etc.
Note that the Peer
objects received in those events may be used, at any time, to send messages to the remote party – like “Shutting down. Goodbye”.
IMPLEMENTATION NOTE: GAT traits (to reduce the number of generic parameters) couldn’t be used here – even after applying this compiler bug workaround https://github.com/rust-lang/rust/issues/102211#issuecomment-1513931928
– the “error: implementation of std::marker::Send
is not general enough” bug kept on popping up in user provided closures that called other async functions.
Variants§
PeerArrived
Happens when a remote party is first made available to the reactive processor (caused either by a new connection or by a reactive protocol transition)
PeerLeft
Happens when the remote party leaves the reactive processor (caused either by a dropped connection or by a reactive protocol transition)
Fields
stream_stats: Arc<dyn StreamExecutorStats + Sync + Send>
LocalServiceTermination
Happens when the local code has commanded the service (and all opened connections) to stop