We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 87f33b8 commit 6176f36Copy full SHA for 6176f36
src/gcoap.rs
@@ -95,6 +95,20 @@ pub trait Handler {
95
fn handle(&mut self, pkt: &mut PacketBuffer) -> isize;
96
}
97
98
+/// A wrapper that implements gnrc::Handler for closures. This allows easy compact writing of
99
+/// ad-hoc handlers.
100
+pub struct ClosureHandler<H>(pub H) where
101
+ H: FnMut(&mut PacketBuffer) -> isize
102
+;
103
+impl<H> Handler for ClosureHandler<H> where
104
105
+{
106
+ fn handle(&mut self, pkt: &mut PacketBuffer) -> isize {
107
+ self.0(pkt)
108
+ }
109
+}
110
+
111
112
// Questionable code starts here
113
114
use riot_sys::libc::{c_uint};
0 commit comments