GitHub user ilsley edited a discussion: Seek implementation has unexpected 
behaviour

I have started using OpenDAL, and it's working great. However, the Seek 
implementation on Buffer caused a subtle bug for me. Specifically, if I have 
understood correctly:
- Seek consumes the input i.e. it can only move forward. Rewind is not possible.
- stream_position always returns 0. 

At least for me, this felt like it was going against standard expectations, 
particularly given the documentation of the 
[Seek](https://doc.rust-lang.org/stable/std/io/trait.Seek.html) trait:

> The Seek trait provides a cursor which can be moved within a stream of bytes.
> The stream typically has a fixed size, allowing seeking relative to either 
> end or the current offset.

This seems to make Buffer's Seek implementation most relevant to forward-only 
parsing of binary files, and less useful (potentially buggy) for random access 
readers. 

An overlapping observation is that I have found the large number of trait 
implementations on Buffer potentially confusing each with overlapping 
approaches and different assumptions; at times I needed to use fully qualified 
names for trait methods. For me, it was non-obvious which methods consume, and 
which do not, and which I should use. Would it perhaps be useful/ergonomic to 
have adapters on Buffer? This could make the underlying behaviour and 
assumptions of each trait clearer.

Alternatively, of course, if you could explain the rationale for the current 
approach that would be much appreciated as this would help me use Buffer 
correctly.


---
**Mailing list thread:** 
https://lists.apache.org/thread/cvgy85fb9px8kl4lm3j4std13l7w11q2


GitHub link: https://github.com/apache/opendal/discussions/7113

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to