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

Easy way to implement limit? #37

Closed
octylFractal opened this issue Feb 6, 2019 · 4 comments
Closed

Easy way to implement limit? #37

octylFractal opened this issue Feb 6, 2019 · 4 comments
Labels

Comments

@octylFractal
Copy link

I want to be able to limit an Input, but it doesn't seem like the functionality exists. I attempted to implement it with a new AbstractInput subclass, but I couldn't understand how head and remaining are supposed to function. I want to know if it would be possible to add this functionality to Input as an extension function, or -- if this is actual trivial to implement on my end -- some direction on how AbstractInput functions.

@altavir
Copy link

altavir commented Nov 25, 2019

I found that I need this feature as well in io-2. Current design gives fairly good idea how to use copy part of Input into new Input, but it seems not possible to make a zero-copy view of Input.

@qwwdfsad
Copy link
Member

In new IO it's relatively easy to implement limit, though it won't be zero-copy (neither it can be by design)

@altavir
Copy link

altavir commented Nov 25, 2019

It is quite easy to do with copy. I have a working example with input to output copy. But the idea is that you seldom need to limit how many bytes could be read and report preliminary EOF, and making complete input copy for that is an overkill. It is not hard to add manual limitation to the Input class, but I am not sure it is strictly necessary. For now workarounds seems rather elegant. I will write again if I hit real problem with this.

@fzhinkin
Copy link
Collaborator

We're rebooting the kotlinx-io development (see #131), all issues related to the previous versions will be closed. Consider reopening it if the issue remains (or the feature is still missing) in a new version.

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

No branches or pull requests

5 participants