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.

Retrieves the total number of bytes of the file

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

Sets the position of the cursor.

The position is specified relative to the beginning of the file.

See also seek for a safe, and slightly more ergonomic way to set the cursor.

Safety

The position must lie inside the extend of the file. Otherwise, the behaviour is undefined.

Sets the cursor to the beginning of the file.

In comparison to seek, this method does not need to check the length of the file or the provided index.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.