pub struct File<'a> { /* private fields */ }Expand description
A file loaded from ROM or data dir into the memory.
Returned by [rom::load] and [data::load] which requires a pre-allocated buffer
of the right size. If the file size is deterimed dynamically,
you might want to use [rom::load_buf] and [data::load_buf] instead
(which will take care of the dynamic allocation).
Implementations§
Source§impl<'a> File<'a>
impl<'a> File<'a>
Sourcepub unsafe fn from_bytes(b: &'a [u8]) -> Self
pub unsafe fn from_bytes(b: &'a [u8]) -> Self
Construct File from raw bytes.
The main purpose of this function is to support convering File
to and from “basic” types, which might be required for implementing
some language interpreters (Lua, Python, etc) for Firefly in Rust.
§Safety
This function allows bypassing type safety and constructing Image
and Font in runtime. Don’t do that. Relying on internal representation
of file formats might make your app incompatible with future Firefly runtimes.
If you need to modify an in-memory image, use Canvas instead.
Sourcepub fn as_bytes(&self) -> &[u8]
pub fn as_bytes(&self) -> &[u8]
Alias for File::data.