nrc / owned-buf

An owned buffer type for reading into possibly uninitialized memory
Apache License 2.0
2 stars 1 forks source link

Limit length #5

Open nrc opened 1 year ago

nrc commented 1 year ago

For fixed size reads or partial writes, you might not want to read/write to the end of the buffer. In the borrowed case, you would just slice for this, but that isn't possible here. So we probably want some mechanism to limit the usable length of the buffer. For writes, we read out of the filled part, so we should have a start limit too. I.e., we want to have a slice view of the underlying buffer.

An alternative is to properly support 'owned slices' but I think this gets complicated and requires reference counting or similar.

nrc commented 1 year ago

I think this is addressed by https://github.com/nrc/owned-buf/commit/dd0fb41aeca08fd1146c8a0847d9c277cb91cbc5 but I'm leaving this issue open until I'm sure it's a good solution