handle events, minimal state machine
This commit is contained in:
@@ -105,6 +105,9 @@ pub trait EventContext: BasicContext {
|
||||
/// Get the peer relevant to the event e.g. message sender,
|
||||
/// disconnected/connected peer.
|
||||
fn peer(&self) -> PeerId;
|
||||
|
||||
/// Treat the event context as a basic context.
|
||||
fn as_basic(&self) -> &BasicContext;
|
||||
}
|
||||
|
||||
/// Basic context.
|
||||
@@ -182,4 +185,8 @@ impl<'a> EventContext for Ctx<'a> {
|
||||
fn peer(&self) -> PeerId {
|
||||
self.peer
|
||||
}
|
||||
|
||||
fn as_basic(&self) -> &BasicContext {
|
||||
&*self
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user