silver-ymz opened a new pull request, #3004:
URL: https://github.com/apache/incubator-opendal/pull/3004

   ## Explanation
   
   `std::istream` is more like `BufRead` in rust, so I expose `struct 
Reader(BufReader<od::BlockingReader>)`. Otherwise, we need to impl a 
`BufReader` in c++ which will bring more unsafe code and it's more difficult to 
maintain.
   
   `std::streambuf` use three following pointers to track buffer state. c++ 
side needs to update these pointers with rust buffer state. My implementation 
is to call 
[`fill_buf`](https://doc.rust-lang.org/1.72.0/std/io/trait.BufRead.html#tymethod.fill_buf)
 and 
[`seek`](https://doc.rust-lang.org/1.72.0/std/io/trait.Seek.html#tymethod.seek) 
in needed and assign 
[`buffer`](https://doc.rust-lang.org/1.72.0/std/io/struct.BufReader.html#method.buffer)
 result to the three pointers. And we call 
[`consume`](https://doc.rust-lang.org/1.72.0/std/io/trait.BufRead.html#tymethod.consume)
 in the next `fill_buf` and `seek` operation to update c++ info for rust side.
   
   <img width="234" alt="image" 
src="https://github.com/apache/incubator-opendal/assets/78400701/79bdbd1a-a99f-41ff-a729-64458cc0baa2";>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to