mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-14 02:21:21 +00:00
Make deriving the NetworkBehaviour more ergonomic (#782)
This commit is contained in:
@ -336,6 +336,15 @@ pub trait NetworkBehaviour<TTopology> {
|
||||
fn poll(&mut self, topology: &mut PollParameters<TTopology>) -> Async<NetworkBehaviourAction<<Self::ProtocolsHandler as ProtocolsHandler>::InEvent, Self::OutEvent>>;
|
||||
}
|
||||
|
||||
/// Used when deriving `NetworkBehaviour`. When deriving `NetworkBehaviour`, must be implemented
|
||||
/// for all the possible event types generated by the various fields.
|
||||
// TODO: document how the custom behaviour works and link this here
|
||||
pub trait NetworkBehaviourEventProcess<TEvent> {
|
||||
/// Called when one of the fields of the type you're deriving `NetworkBehaviour` on generates
|
||||
/// an event.
|
||||
fn inject_event(&mut self, event: TEvent);
|
||||
}
|
||||
|
||||
/// Parameters passed to `poll()` that the `NetworkBehaviour` has access to.
|
||||
// TODO: #[derive(Debug)]
|
||||
pub struct PollParameters<'a, TTopology: 'a> {
|
||||
|
Reference in New Issue
Block a user