pub trait FileSystem {
// Required methods
fn file_exists(&mut self, path: &str) -> bool;
fn get_file_mime_type(&mut self, path: &str) -> String;
fn get_file_charset(&mut self, path: &str) -> String;
fn open_file(&mut self, path: &str) -> Option<Vec<u8>>;
}Expand description
This is used for loading File URLs (eg, file:///page.html).
You can provide the library with your own FileSystem implementation so that file assets are loaded from your own pipeline (useful if you would like to encrypt/compress your file assets or ship it in a custom format).
AppCore automatically provides a platform-specific implementation of this that loads files from
a local directory when you call App::new
If you are using Renderer::create instead, you will need to provide your own implementation
via platform::set_filesystem.
To provide your own custom FileSystem implementation, you should implement
this trait, and then pass an instance of your struct to
platform::set_filesystem before calling Renderer::create or App::new.
Required Methods§
Sourcefn file_exists(&mut self, path: &str) -> bool
fn file_exists(&mut self, path: &str) -> bool
Check if file path exists, return true if exists.
Sourcefn get_file_mime_type(&mut self, path: &str) -> String
fn get_file_mime_type(&mut self, path: &str) -> String
Get the mime-type of the file (eg “text/html”).
This is usually determined by analyzing the file extension.
If a mime-type cannot be determined, this should return “application/unknown”.
Sourcefn get_file_charset(&mut self, path: &str) -> String
fn get_file_charset(&mut self, path: &str) -> String
Get the charset / encoding of the file (eg “utf-8”, “iso-8859-1”).
This is only applicable for text-based files (eg, “text/html”, “text/plain”) and is usually determined by analyzing the contents of the file.
If a charset cannot be determined, a safe default to return is “utf-8”.