Skip to main content

Files

Trait Files 

Source
pub trait Files {
    // Required methods
    fn bytes(&self, path: &str) -> Option<Vec<u8>>;
    fn list(&self, path: &str) -> Option<Vec<String>>;

    // Provided methods
    fn read(&self, path: &str) -> Option<String> { ... }
    fn image(&self, path: &str) -> Option<Result<Arc<ImageFile>, String>> { ... }
    fn font(&self, path: &str) -> Option<Result<Arc<FontFile>, String>> { ... }
}
Expand description

Reads a design’s files by their path from the top of the served folder.

Required Methods§

Source

fn bytes(&self, path: &str) -> Option<Vec<u8>>

A file’s bytes: a design’s text, an Image’s file or a font file.

Source

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

The names of the files directly in the folder at path, sorted; None when there is no such folder. A font folder is read this way.

Provided Methods§

Source

fn read(&self, path: &str) -> Option<String>

A design file’s text.

Source

fn image(&self, path: &str) -> Option<Result<Arc<ImageFile>, String>>

The image file at path, decoded, or why it doesn’t decode; None when there is no such file. A store that keeps files between resolves keeps their decoded images too, so a save doesn’t decode them again.

Source

fn font(&self, path: &str) -> Option<Result<Arc<FontFile>, String>>

The font file at path, checked, or why it isn’t one; None when there is no such file. A store that keeps files between resolves keeps them checked too.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Files for HashMap<String, String>

Source§

fn bytes(&self, path: &str) -> Option<Vec<u8>>

Source§

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

Implementors§