mathias234/binary_rw

Expose file metadata (or stream length)?

Closed this issue · 1 comments

tmpfs commented

I have a situation where I am using FileStream and I want to check the file length but I don't want to create a new File just to read the meta data. We could:

  1. Expose &File in FileStream
  2. Expose self.file.metadata() in FileStream
  3. Support a len() method on the Stream trait

My preference would be for 3) but I wonder what you think?

I can imagine a situation where there may be streams that don't have a known length so if we do support a len() function maybe it should look like:

fn len(&self) -> Option<usize>;

But we do know the length at the moment for MemoryStream and FileStream so maybe cross that bridge later.

tmpfs commented

I have submitted #32 to address this, hope you think this is worthwhile too 🙏