Implementing ByteStream interuption on infinite stream#13552
Implementing ByteStream interuption on infinite stream#13552IanManske merged 13 commits intonushell:mainfrom
Conversation
WindSoilder
left a comment
There was a problem hiding this comment.
Thank you! The idea of using ByteStream::from_fn and reader.bytes looks good to me!
Just some comments for a corner case and some test cases
WindSoilder
left a comment
There was a problem hiding this comment.
Thank you for the update! I left some comments about the position of tests. And CI is failed, you need to run cargo fmt to fix it :)
c1c96b4 to
3d7519e
Compare
|
All requested changes have been completed 😄 |
There was a problem hiding this comment.
Thanks for this PR! The take and skip commands already support binary streams, and their code could be reused for this command. I.e., bytes at ..$n is essentially take $n, bytes at $n.. is skip $n, and bytes at $n..$m is skip $n | take ($m - $n). I think it would make more sense if the binary stream handling was extracted out from those commands into a separate file and then reused across all these commands (skip, take, and bytes at).
d4abbf3 to
b7b29ac
Compare
I will take a look at this |
|
Sorry, I should I have linked the code I was talking about. The https://github.com/nushell/nushell/blob/main/crates/nu-command/src/filters/skip/skip_.rs#L98C29-L114 You can reuse this code to implement |
|
Dw I got what you meant, I just wanted to tidy up the code first |
simon-curtis
left a comment
There was a problem hiding this comment.
All changes have been made. I have merged the logic for filters::skip and filters::take into the ByteStream impl along with a ByteStream::slice function - which is now used in bytes::at. I've also added some more tests for regression
IanManske
left a comment
There was a problem hiding this comment.
Thanks for all the tests and refactoring! A few comments:
|
Thanks for the feedback btw, I'm learning a lot |
|
This also closes #13668 |
IanManske
left a comment
There was a problem hiding this comment.
Thanks for the changes! This is almost good to go, just a few last things.
|
I have moved logic into using the core IntRange instead of SubBytes as not to duplicate logic. I have added a couple of functions on the Range to resolve the absolute range values where a length is known too, returning the original Bound value to allow the caller to apply the index as they wish. In our case we both apply it by slicing Vec and using the new ByteStream::slice function. I am still testing and need to format so hold out for a min |
310a78b to
6733f73
Compare
|
what's the status here? |
|
I will fast forward and resolve merge conflicts tonight after work. AFAIK everything works and would be ready to merge in |
- Removed explicit type annotation. - Changed panic to assert_eq
Co-authored-by: Ian Manske <ian.manske@pm.me>
6733f73 to
69f3738
Compare
|
Hi, @IanManske . Can you take the last review when you get time? |
IanManske
left a comment
There was a problem hiding this comment.
Thanks! This looks good at a glance, we'll land this to start testing in the wild.

Description
This PR should address #13530 by explicitly handling ByteStreams.
The issue can be replicated easily on linux by running:
Would leave the output hanging and with no way to cancel it, this was likely because it was trying to collect the input stream and would not complete.
I have also put in an error to say that using negative offsets for a bytestream without a length cannot be used.
User-Facing Changes
No operation changes, only the warning you get back for negative offsets
Tests + Formatting
Ran
toolkit check prwith no errors or warningsManual testing of the example commands above