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

Provide a Reader::from_read interface #10

Open
RoloEdits opened this issue Feb 17, 2024 · 1 comment
Open

Provide a Reader::from_read interface #10

RoloEdits opened this issue Feb 17, 2024 · 1 comment

Comments

@RoloEdits
Copy link

As far as I can see, the only API for getting a Reader is using from_str and new, both of which take a &str.

Having something like:

Reader::from_read<R: Read>(read: R)

would make it simple to pass in a File, for example, without glue code to get a &str or bytes, and passing it to the current interface.

@bluk
Copy link
Owner

bluk commented Feb 26, 2024

It would be a nice convenience method. One issue is that the parser doesn't own the underlying string, so perhaps a new type would need to be created that owns the bytes and the current position.

For my use cases, I use memmap2 or am reading from a database which is why I borrow the bytes.

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

No branches or pull requests

2 participants