Struct heapfile::HeapFile

source ·
pub struct HeapFile { /* private fields */ }
Expand description

A file in memory that is backed by the heap, i.e., a Vec.

Implementations§

source§

impl HeapFile

source

pub fn create(name: String, parent: &DirRef) -> Result<FileRef, &'static str>

Creates a new file with empty content in the given parent directory. No allocation is performed.

source

pub fn from_vec( vec: Vec<u8>, name: String, parent: &DirRef ) -> Result<FileRef, &'static str>

Creates a new HeapFile in the given parent directory with the contents of the given Vec. No additional allocation or reallocation is performed.

Trait Implementations§

source§

impl ByteReader for HeapFile

source§

fn read_at( &mut self, buffer: &mut [u8], offset: usize ) -> Result<usize, IoError>

Reads bytes of data from this reader into the given buffer. Read more
source§

impl ByteWriter for HeapFile

source§

fn write_at(&mut self, buffer: &[u8], offset: usize) -> Result<usize, IoError>

Writes bytes of data from the given buffer to this writer. Read more
source§

fn flush(&mut self) -> Result<(), IoError>

Flushes this writer’s output stream, ensuring all contents in intermediate buffers are fully written out.
source§

impl File for HeapFile

source§

fn as_mapping(&self) -> Result<&MappedPages, &'static str>

Returns a view of this file as an immutable memory-mapped region.
source§

impl FsNode for HeapFile

source§

fn get_name(&self) -> String

Returns the string name of the node
source§

fn get_parent_dir(&self) -> Option<DirRef>

Returns the parent directory of the current node.
source§

fn set_parent_dir(&mut self, new_parent: WeakDirRef)

Sets this node’s parent directory. This is useful for ensuring correctness when inserting or removing files or directories from their parent directory.
§

fn get_absolute_path(&self) -> String

Recursively gets the absolute pathname as a String
source§

impl KnownLength for HeapFile

source§

fn len(&self) -> usize

Returns the length (size in bytes) of this I/O stream or device.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.