Trait to get the size of an I/O object.
Implementing this for a ReadAt or WriteAt makes it easier for users to predict whether they will read past end-of-file. However, it may not be possible to implement for certain readers or writers that have unknown size.
use positioned_io::Size; let file = try!(File::open("foo.txt")); let size = try!(file.size()); assert_eq!(size, Some(22)); // Special files probably don't have a size. let file = try!(File::open("/dev/stdin")); let size = try!(file.size()); assert_eq!(size, None);
Get the size of this object, in bytes.
This function may return Ok(None) if the size is unknown, for example if a file is a pipe.
If a positive value is returned, it should be the value such that reading at greater offsets always yields end-of-file.