pub enum File {
Native(File),
}
Expand description
synchronous (native) / asynchronous (web) file API
Variants§
Implementations§
source§impl File
impl File
sourcepub fn read_binary(&mut self) -> Result<Vec<u8>, IoError>
pub fn read_binary(&mut self) -> Result<Vec<u8>, IoError>
Once the file has been loaded (see File::is_ready
), returns the file content as Vec<u8>
sourcepub fn read_text(&mut self) -> Result<String, IoError>
pub fn read_text(&mut self) -> Result<String, IoError>
Once the file has been loaded (see File::is_ready
), returns the file content as a String
sourcepub fn is_ready(&mut self) -> bool
pub fn is_ready(&mut self) -> bool
return true if the file has been loaded
On native target, files are loaded synchronously.
As soon as FileSystem::open
returns, the file is ready.
File::read_binary
and File::read_text
can be called immediately.
On web target, files are loaded asynchronously.
You have to poll File::is_ready
until it returns true.
Only then you can call File::read_binary
or File::read_text
.