file_storage/op/file/write/
write_empty.rs

1use crate::{Error, FilePath};
2
3impl FilePath {
4    //! Write Empty
5
6    /// Writes an empty file.
7    ///
8    /// Returns `Ok(())`.
9    /// Returns `Err(FileAlreadyExists)` if the file already exists.
10    pub fn write_empty(&self) -> Result<(), Error> {
11        self.write_slice([0u8; 0])
12    }
13
14    /// Writes an empty file if the file does not exist.
15    ///
16    /// Returns `Ok(true)` if the file was written.
17    /// Returns `Ok(false)` if the file already exists.
18    pub fn write_empty_if_not_exists(&self) -> Result<bool, Error> {
19        self.write_slice_if_not_exists([0u8; 0])
20    }
21}