Skip to content
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

Merged
merged 2 commits into from
May 12, 2022

Conversation

brendanzab
Copy link
Member

@brendanzab brendanzab commented May 12, 2022

This implements a repeat_until_end format, along with an Array 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.

Copy link
Contributor

@wezm wezm left a 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.

@brendanzab brendanzab merged commit 0c6a303 into yeslogic:main May 12, 2022
@brendanzab brendanzab deleted the formats/repeat-until-end branch May 12, 2022 06:52
Comment on lines +368 to +370
Because the repeat format does not have a predefined length, it is
[represented](#format-representations) as a dynamically sized
[array type](#array-types):
Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

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.

Comment on lines +201 to +207
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),
Copy link
Contributor

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?

Copy link
Member Author

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.

@brendanzab
Copy link
Member Author

Sorry for being hasty in merging this @mikeday! 😳

@mikeday
Copy link
Contributor

mikeday commented May 12, 2022

No problems with the merge, just curious!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants