Hacker News new | ask | show | jobs
by steveklabnik 2612 days ago
That is all here: https://doc.rust-lang.org/stable/std/fs/struct.File.html

These failure patterns are handled by each method, for example,

  pub fn open<P: AsRef<Path>>(path: P) -> Result<File>
that Result will return an error if the file can't be opened, etc. Let's say you want to write some bytes, that's

  fn write(&mut self, buf: &[u8]) -> Result<usize>
This also returns Result, so if you've opened the file, but the disk is now out of space, this will return an error, etc.