-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decode multiple messages from the same buffer #413
Comments
Thank you for your issue! You need to capture the decoder, which has an input method, that returns the remaining unparsed input. https://docs.rs/rasn/latest/rasn/uper/struct.Decoder.html#method.input |
Thanks, that does seem to work - but it is a bit awkward to use, as my messages are byte-aligned and the padding prevents me from re-using the decoder:
Is there a nicer way to achieve what I am looking to do? |
I added new API for OER codec to solve the same issue: Lines 18 to 22 in d97c44d
Maybe there is a chance to add similar? |
This does not do any extra allocations. It just moves the reference of the original input slice. |
Well, hrm. If the messages are truly one after the other, without padding, that function wouldn't work. I think maybe for UPER it would be better to have some kind of flag for the Decoder to indicate that the messages are byte-aligned one after another and then you can just call T::decode multiple times with the same decoder, same as it would work right now? Not quite sure |
Thank you for your issue! I think how I would want to solve this issue is by providing an iterator struct that is a wrapper around decoder. let iter = rasn::de::iter::<rasn::uper::Decoder>(input);
loop {
while let Some(Ok(value)) = iter.next() {
// handle value
}
iter.append_bytes(new_data);
} |
Thank you for the reply! Do you expect a new message to be aligned at the next byte border then, or not? Right now the |
I believe all complete encodings are byte aligned no? |
If that is the case, then maybe the problem is there's a bug in the UPER decoder? Because the |
It is likely that they we haven't set it so the UPER parses the padding at the end of the encoding. |
Basically, iiuic, you'd need an entry function that isn't |
I can take a look for this over weekend. At least the |
How can I decode multiple UPER-encoded messages from a buffer where they are stored directly after each other, without delimiter?
decode
just takes a buffer, but neither shrinks it when reading bytes nor returning how many bytes it read to parse the first message. Initially I thought the impl ofDecode
forVec<T>
whereT: Decode
would help me, but that assumes that the messages are stored in an asn1 sequence rather than immediately one after another. I didn't see any kind of API to read this efficiently, did I overlook that or could it be added like adecode_multiple
(would require alloc of course) or something like that?The text was updated successfully, but these errors were encountered: