Parsing byte streams

Sometimes, you might want to parse byte streams or byte slices to get valuable data. An example could be parsing a TCP byte stream to get HTTP data. Thanks to Rust and the Nom crate, we have an extremely efficient parser generator, which will not add extra overhead by copying data within your crate.

With the Nom crate, you create functions that will read the input data byte by byte and return the parsed data. The aim in this section is not to master the Nom crate, but to understand its power and point you to the appropriate documentation. So, let's see the adapted example from Zbigniew Siciarz's 24 days of Rust (https://siciarz.net/24-days-rust-nom-part-1/), where he showed a short example of how to parse the first line ...

Get Rust High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.