Skip to main content

ProjectFiles

Trait ProjectFiles 

Source
pub trait ProjectFiles {
    // Required methods
    fn read(&self, path: &str) -> Result<Vec<u8>>;
    fn list(&self, prefix: &str) -> Vec<String>;

    // Provided methods
    fn exists(&self, path: &str) -> bool { ... }
    fn root(&self) -> Option<&Path> { ... }
}
Expand description

Read/list access to a game project’s files.

Required Methods§

Source

fn read(&self, path: &str) -> Result<Vec<u8>>

Read the file at project-relative POSIX path.

§Errors

Fails when the file does not exist or cannot be read.

Source

fn list(&self, prefix: &str) -> Vec<String>

Recursively list every file under prefix (a project-relative POSIX directory; "" lists the whole project), as project-relative POSIX paths, sorted lexicographically (stable). An absent prefix yields an empty list, not an error.

Provided Methods§

Source

fn exists(&self, path: &str) -> bool

Whether a readable file exists at path.

Source

fn root(&self) -> Option<&Path>

The on-disk project root, when backed by a real directory. Native conveniences (the save-file default location, hot-reload watching) use this; in-memory projects return None.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§