Struct semihosting_files::File [−][src]
pub struct File { /* fields omitted */ }
Expand description
A reference to an open file on the host system.
Depending on the options that it was opened with, files can be read and/or written.
Files are auromatically closed when they are dropped. If an error occurs while dropping, the error is silently swallowed.
Use close
if these errors should be explicitly handled.
Because all semihosting operations are very slow, buffering reads and writes might be beneficial.
As the semihosting operations don’t return a specific error when they fail, most methods just return a Result<_, ()>
.
Implementations
Opens the file with the given mode.
Tries to write all of buffers bytes into the file, and returns the number of bytes that were actually written.
Closes the file.
The file is also closed when it the file is dropped. However this method is more explicit and allows to check if an error happenend while closing the file.
If an error occured, the unclosed file is returned.
Tries to read buf.len()
bytes from the file and returns the number of bytes that was read into the buffer.
The result Ok(0usize)
suggests that EOF has been reached.
Sets the read/write-cursor to the specified position This actually consists of two semihosting operations: One to get the length, and another to set the cursor
If you want to set the cursor to the beginning of the file, use rewind
instead.
see also: seek_unchecked