-
Notifications
You must be signed in to change notification settings - Fork 14
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
Implement a repeat_until_end
format.
#361
Implement a repeat_until_end
format.
#361
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍 I was expecting it to require more code when I read the PR description.
Because the repeat format does not have a predefined length, it is | ||
[represented](#format-representations) as a dynamically sized | ||
[array type](#array-types): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to access the length once parsed? Do we need to mention that the repeat format doesn't need to be of fixed size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think I'll need to get up to adding sizing to this reference, like how I talk about the host representation types.
Are you thinking the byte length? Or the number of elements in the array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of number of elements in the array, as the byte length could be determined by following it with a pos.
Err(err) => match err.kind() { | ||
io::ErrorKind::UnexpectedEof => { | ||
// FIXME: should this be set to the end of the current stream? | ||
reader.seek(SeekFrom::Start(current_pos))?; | ||
return Ok(Arc::new(Value::ArrayLit(elems))); | ||
} | ||
_ => return Err(err), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this allow trailing random bytes at the end of the stream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yeah it does - I was thinking of maybe adding a repeat_until_end_exact
format.
Sorry for being hasty in merging this @mikeday! 😳 |
No problems with the merge, just curious! |
This implements a
repeat_until_end
format, along with anArray
type with no length. We could add more repeat formats later in order to address the needs of #352.These commits were taken from #310.