Closed marmistrz closed 4 years ago
Okay, it definitely should not just be hanging if newlines are omitted. Gonna look into this ASAP.
I retested it and I must've mistaken the freezes for just stdin waiting for more input. Sorry for that.
I also have a patch which allows reading single message. Let me know if you're interested in me upstreaming it.
It doesn't actually hang, just returns an empty MessageList. It is technically an error in the input and as explained in the docs, parse() ignores errors. If you try parse_strict() you will actually get an error back and if you try parse_with_unknown() you will actually get a UciMessage::Unknown back.
Although I can see how it could be confusing, I guess you would except to get the parsed message back even if it lacks a newline.
Ah, I see you already figured it out by yourself. Sure, send over the patch or do a pull request and I'll incorporate it into 0.10.0.
Hi,
I tried using your crate to parse UCI from stdin, synchronously.
It appears that the commands are not properly parsed if they don't contain a trailing newline and such is stripped by
read_line
. Moreover,parse
just hangs and doesn't return any error.On the other hand, I'm wondering if it wouldn't be better for
parse
to accept any type that implementsBufRead
. It makes no sense to iterate over the messages if we read stdin line-by-line.