Skip to main content

ConfigFiles

Trait ConfigFiles 

pub trait ConfigFiles {
    // Required methods
    fn read(&self, file: &ConfigPath) -> Result<Vec<u8>, ConfigFileError>;
    fn write(
        &self,
        file: &ConfigPath,
        bytes: &[u8],
    ) -> Result<(), ConfigFileError>;
    fn list(
        &self,
        folder: &ConfigPath,
    ) -> Result<Vec<ConfigEntry>, ConfigFileError>;
    fn stat(
        &self,
        path: &ConfigPath,
    ) -> Result<Option<ConfigStat>, ConfigFileError>;
}
Expand description

The calling mod’s files in config/: read, write, list and stat. Every call takes &self, so reads and writes work through &dyn Host on both sides; a write changes the file, not the host. The game’s reload poll (config_reloading) sees a written registered config as any edit.

Required Methods§

fn read(&self, file: &ConfigPath) -> Result<Vec<u8>, ConfigFileError>

The file’s bytes, at most CONFIG_FILE_MAX.

fn write(&self, file: &ConfigPath, bytes: &[u8]) -> Result<(), ConfigFileError>

Replaces the file’s bytes, at most CONFIG_FILE_MAX, making its folders when missing. The new bytes replace the old ones at once: a reader never sees half a write.

fn list(&self, folder: &ConfigPath) -> Result<Vec<ConfigEntry>, ConfigFileError>

The entries of a folder, by name, at most CONFIG_LIST_MAX.

fn stat(&self, path: &ConfigPath) -> Result<Option<ConfigStat>, ConfigFileError>

What is at path; None where nothing is.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§