handle events, minimal state machine

This commit is contained in:
Robert Habermeier
2016-12-15 21:51:08 +01:00
parent 72f7391551
commit 9c7340307e
4 changed files with 170 additions and 26 deletions

View File

@@ -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
}
}