-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Problem solved by the enhancement
I'm using in-memory bytes reader that I'm filling incrementally (this push-based model as opposed to std::io::Read
's pull model has its uses and I'm able to utilize json stream reader in async
context this way) as the stream parsing goes on, however the fact that JsonStreamReader
takes ownership and hides access to the reader makes it inconvenient, requiring some technique for shared state access.
This essentially could be avoided if filling data into underlying reader doesn't need to be done concurrently with reading data from the stream reader and regular rules of Rust's memory access would be satisfied.
Enhancement description
Making reader
field public would suffice, alternatively add pub fn reader(&self) -> &R
and pub fn reader_mut(&mut self) -> &mut R
accessors.
Alternatives / workarounds
Currently I'm using struct Handle(std::rc::Rc<std::cell::RefCell<R>>)
implementing std::io::Read
for it with dynamic borrows, but clearly that means adding a chunk of boilerplate code and sub-optimal performance.