diff options
author | Profpatsch <mail@profpatsch.de> | 2021-03-30T02·49+0200 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2021-04-01T07·28+0000 |
commit | 59a9955d753d8f9deb705d36922f6e8d77307f1d (patch) | |
tree | 525f8269bfa15160b58d2d73498306c0899c837e /users/sterni/nix/url | |
parent | 53d8dd6a1e56533dbe33a711bdec792cd477f0c7 (diff) |
feat(users/Profpatsch/netencode): fully streaming parser r/2382
In order to arbitrarily split netencode over multiple reads, we need to make the parser completely streaming, so that it recognizes all cases where it needs more input. Luckily, this is fairly trivial, after working around a bunch of overeager parsing. The tricky part was the giant `alt`, where inner parsers would start consuming input and thus become incomplete when they fail afterwards. Sinc the format *always* starts the different types with one discriminator char, we can use that to instantly return the parser and try the next one instead. The other tricky part was that lists and records would parse all inner elements and then choke on the empty string after the last element, because the inner parser would consume at least the descriminator, and an empty string is always `Incomplete`. We wrap these into a small combinator which plays nice with `many0` in that regard. Change-Id: Ib8d15d9a7cab19d432c6b24a35fcad6a5a72b246 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2704 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de> Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'users/sterni/nix/url')
0 files changed, 0 insertions, 0 deletions