pub trait WritableSystem: System {
// Required methods
fn create_new_file(&self, path: &SystemPath) -> Result<()>;
fn write_file_bytes(&self, path: &SystemPath, content: &[u8]) -> Result<()>;
fn create_directory_all(&self, path: &SystemPath) -> Result<()>;
fn dyn_clone(&self) -> Box<dyn WritableSystem>;
// Provided methods
fn write_file(&self, path: &SystemPath, content: &str) -> Result<()> { ... }
fn get_or_cache(
&self,
path: &SystemPath,
read_contents: &dyn Fn() -> Result<String>,
) -> Result<Option<SystemPathBuf>> { ... }
}Expand description
System trait for non-readonly systems.
Required Methods§
Sourcefn create_new_file(&self, path: &SystemPath) -> Result<()>
fn create_new_file(&self, path: &SystemPath) -> Result<()>
Creates a file at the given path.
Returns an error if the file already exists.
Sourcefn write_file_bytes(&self, path: &SystemPath, content: &[u8]) -> Result<()>
fn write_file_bytes(&self, path: &SystemPath, content: &[u8]) -> Result<()>
Writes the given content to the file at the given path.
Sourcefn create_directory_all(&self, path: &SystemPath) -> Result<()>
fn create_directory_all(&self, path: &SystemPath) -> Result<()>
Creates a directory at path as well as any intermediate directories.
fn dyn_clone(&self) -> Box<dyn WritableSystem>
Provided Methods§
Sourcefn write_file(&self, path: &SystemPath, content: &str) -> Result<()>
fn write_file(&self, path: &SystemPath, content: &str) -> Result<()>
Writes the given content to the file at the given path.
Sourcefn get_or_cache(
&self,
path: &SystemPath,
read_contents: &dyn Fn() -> Result<String>,
) -> Result<Option<SystemPathBuf>>
fn get_or_cache( &self, path: &SystemPath, read_contents: &dyn Fn() -> Result<String>, ) -> Result<Option<SystemPathBuf>>
Reads the provided file from the system cache, or creates the file if necessary.
Returns Ok(None) if the system does not expose a suitable cache directory.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".