with_context on LightSync

This commit is contained in:
Robert Habermeier
2017-02-02 17:02:46 +01:00
parent fd44dcda15
commit 3b9ac7648c
3 changed files with 14 additions and 4 deletions

View File

@@ -674,6 +674,16 @@ impl LightSync {
subprotocol_name: params.subprotocol_name,
})
}
/// Execute a closure with a protocol context.
pub fn with_context<F, T>(&self, f: F) -> Option<T>
where F: FnOnce(&::light::net::BasicContext) -> T
{
self.network.with_context_eval(
self.subprotocol_name,
move |ctx| self.proto.with_context(ctx, f),
)
}
}
impl ManageNetwork for LightSync {