Struct RomFs

Source
pub struct RomFs<'a> { /* private fields */ }
Expand description

Represents a ROM Filing System (ROMFS), as backed by a byte slice in memory.

Implementations§

Source§

impl<'a> RomFs<'a>

Source

pub fn new(contents: &'a [u8]) -> Result<RomFs<'a>, Error>

Mount a ROMFS using a given block of RAM

Source

pub fn find(&self, file_name: &str) -> Option<Entry<&str, &[u8]>>

Find a file in the ROMFS, by name.

Source

pub fn construct<S, T>( buffer: &mut [u8], entries: &[Entry<S, T>], ) -> Result<usize, Error>
where S: AsRef<str>, T: AsRef<[u8]>,

Construct a ROMFS into the given buffer.

Tells you how many bytes it used of the given buffer.

The buffer must be large enough otherwise an error is returned - see Self::size_required to calculate the size of buffer required.

Source

pub fn construct_into<S, T, SINK>( buffer: &mut SINK, entries: &[Entry<S, T>], ) -> Result<usize, Error>
where S: AsRef<str>, T: AsRef<[u8]>, SINK: Write,

Construct a ROMFS into the given embedded-io byte sink.

Tells you how many bytes it wrote to the given buffer.

Source

pub fn size_required<S, T>(entries: &[Entry<S, T>]) -> usize
where S: AsRef<str>, T: AsRef<[u8]>,

Tells you how many bytes you need to make a ROMFS from these entries.

Trait Implementations§

Source§

impl<'a> IntoIterator for &'a RomFs<'a>

Source§

type Item = Result<Entry<&'a str, &'a [u8]>, Error>

The type of the elements being iterated over.
Source§

type IntoIter = RomFsEntryIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for RomFs<'a>

Source§

type Item = Result<Entry<&'a str, &'a [u8]>, Error>

The type of the elements being iterated over.
Source§

type IntoIter = RomFsEntryIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RomFs<'a>

§

impl<'a> RefUnwindSafe for RomFs<'a>

§

impl<'a> Send for RomFs<'a>

§

impl<'a> Sync for RomFs<'a>

§

impl<'a> Unpin for RomFs<'a>

§

impl<'a> UnwindSafe for RomFs<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.