tenda_runtime/
platform.rs

1use std::fmt::Debug;
2
3#[non_exhaustive]
4pub enum FileErrorKind {
5    NotFound,
6    PermissionDenied,
7    AlreadyExists,
8    Other,
9}
10
11pub trait Platform: Debug {
12    fn println(&self, message: &str);
13    fn print(&self, message: &str);
14    fn write(&self, message: &str);
15    fn read_line(&self) -> String;
16    fn rand(&self) -> f64;
17    fn read_file(&self, path: &str) -> Result<String, FileErrorKind>;
18    fn write_file(&self, path: &str, content: &str) -> Result<(), FileErrorKind>;
19    fn remove_file(&self, path: &str) -> Result<(), FileErrorKind>;
20    fn list_files(&self, path: &str) -> Result<Vec<String>, FileErrorKind>;
21    fn create_dir(&self, path: &str) -> Result<(), FileErrorKind>;
22    fn remove_dir(&self, path: &str) -> Result<(), FileErrorKind>;
23    fn list_dirs(&self, path: &str) -> Result<Vec<String>, FileErrorKind>;
24    fn current_dir(&self) -> Result<String, FileErrorKind>;
25    fn file_append(&self, path: &str, content: &str) -> Result<(), FileErrorKind>;
26    fn args(&self) -> Vec<String>;
27    fn exit(&self, code: i32);
28    fn sleep(&self, seconds: f64);
29    fn date_now(&self) -> i64;
30    fn timezone_offset(&self) -> i32;
31}