Skip to content

Conversation

rapha
Copy link
Contributor

@rapha rapha commented Apr 24, 2015

No description provided.

@rust-highfive
Copy link
Contributor

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@brson
Copy link
Contributor

brson commented Apr 24, 2015

r? @alexcrichton

@rust-highfive rust-highfive assigned alexcrichton and unassigned brson Apr 24, 2015
@alexcrichton
Copy link
Member

This seems like it's very similar to .chain() on many readers themselves, is there a reason that primitive doesn't suffice here?

@rapha
Copy link
Contributor Author

rapha commented Apr 24, 2015

Hmm, chain seems to concatenate two readers, but this is an adaptor from a plain Iterator<Vec<u8>>, for example, to a Reader. Have I understood chain correctly? Would a better name, like ByteIteratorReader, or doc make this clearer?

@alexcrichton
Copy link
Member

Right, you can use an Iterator as well, but you can also call .chain successively. This seems like a pretty niche and/or specialized I/O construct which looks like it can be built with the existing constructs, which is why I was curious why chain wasn't sufficient.

@rapha
Copy link
Contributor Author

rapha commented Apr 24, 2015

The use case is actually to replace the old ChanReader in a generic way.

Given a Receiver<Vec<u8>> I want to be able to read from it. One of the
tests does that. Is there another way?
On 25 Apr 2015 9:02 am, "Alex Crichton" [email protected] wrote:

Right, you can use an Iterator as well, but you can also call .chain
successively. This seems like a pretty niche and/or specialized I/O
construct which looks like it can be built with the existing constructs,
which is why I was curious why chain wasn't sufficient.


Reply to this email directly or view it on GitHub
#24787 (comment).

@alexcrichton
Copy link
Member

I do agree that there's not necessarily a drop-in replacement for the old ChanReader, but this seems like a much more niche use case today and it's always possible to provide these sorts of constructs in your own crate.

@rapha
Copy link
Contributor Author

rapha commented Apr 26, 2015

What I need to do is something like reader.read_u64::<BigEndian>() reading from a Receiver<Vec<u8>>. I don't think that's possible currently.

Perhaps I'd be better off creating a separate cargo project for it?

@alexcrichton
Copy link
Member

Yeah I think that this is best served starting off as a crate outside the standard library, and perhaps if it works well we can move it inside! For now though I'm going to close this for the prior reasons, but thanks for the PR!

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.

4 participants