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:
- Expose
&File
inFileStream
- Expose
self.file.metadata()
inFileStream
- Support a
len()
method on theStream
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.