Created
January 2, 2016 02:22
-
-
Save tailhook/1f9bc0d8e8a7afed70d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Function signature is simplified a bit | |
| fn bytes_received(self, buf, ..) -> Response<..> { | |
| match self { | |
| PacketStart => (PacketLength, Bytes(4), next_timeout()) | |
| PacketLength => { | |
| let len = buf.read_u32(); | |
| (PacketEnd, Bytes(len), next_timeout()) | |
| } | |
| Packet => { | |
| parse_packet(&buf[..]); | |
| (PacketLength, Bytes(4), next_timeout()) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment