PlatformAPI

Trait PlatformAPI 

Source
pub trait PlatformAPI: Debug {
    // Required methods
    fn get_lang_files(&self, lang_path: &Path) -> Result<Vec<PathBuf>, Error>;
    fn get_lang_path(&self, lang_file: &Path) -> Result<PathBuf, Error>;
    fn get_lang_file_name(&self, lang_file: &Path) -> Option<OsString>;
    fn get_lang_reader(&self, lang_file: &Path) -> Result<Box<[u8]>, Error>;
    fn write_lang_file(
        &self,
        lang_file: &Path,
        translation_map: HashMap<String, String>,
    ) -> Result<(), Error>;
    fn show_input_dialog(&self, text: &str) -> Result<String, NativeError>;

    // Provided methods
    fn print(&mut self, text: &str) { ... }
    fn println(&mut self, text: &str) { ... }
    fn print_error(&mut self, text: &str) { ... }
    fn println_error(&mut self, text: &str) { ... }
}
Expand description

This trait is used to abstract some io functionality

Required Methods§

Source

fn get_lang_files(&self, lang_path: &Path) -> Result<Vec<PathBuf>, Error>

Returns all files inside the folder located at lang_path

§Arguments
  • lang_path - Path to the folder
Source

fn get_lang_path(&self, lang_file: &Path) -> Result<PathBuf, Error>

Returns the canonical path of the file located at lang_file

§Arguments
  • lang_file - Path to the file
Source

fn get_lang_file_name(&self, lang_file: &Path) -> Option<OsString>

Return the file name of the file located at lang_file

§Arguments
  • lang_file - Path to the file
Source

fn get_lang_reader(&self, lang_file: &Path) -> Result<Box<[u8]>, Error>

Returns a Box<u8> for the file located at lang_file

§Arguments
  • lang_file - Path to the file
Source

fn write_lang_file( &self, lang_file: &Path, translation_map: HashMap<String, String>, ) -> Result<(), Error>

Writes a translation file

§Arguments
  • lang_file - Path to the file
  • translation_map - The map of all translations
Source

fn show_input_dialog(&self, text: &str) -> Result<String, NativeError>

Returns the value inputted by the user

§Arguments
  • text: The text prompt to be shown to the user

Provided Methods§

Source

fn print(&mut self, text: &str)

Prints to standard output without newline

§Arguments
  • text: The text to be outputted
Source

fn println(&mut self, text: &str)

Prints to standard output with newline

§Arguments
  • text: The text to be outputted
Source

fn print_error(&mut self, text: &str)

Prints to error output without newline

§Arguments
  • text: The text to be outputted
Source

fn println_error(&mut self, text: &str)

Prints to error output with newline

§Arguments
  • text: The text to be outputted

Implementors§