Struct TmpFS

Source
pub struct TmpFS {
    mounted: bool,
    mount_point: String,
    root: RwLock<TmpNode>,
    max_memory: usize,
    current_memory: Mutex<usize>,
}
Expand description

TmpFS - RAM-only filesystem

Fields§

§mounted: bool§mount_point: String§root: RwLock<TmpNode>

Root directory of the filesystem

§max_memory: usize

Maximum memory usage in bytes (0 = unlimited)

§current_memory: Mutex<usize>

Current memory usage in bytes

Implementations§

Source§

impl TmpFS

Source

pub fn new(max_memory: usize) -> Self

Create a new TmpFS instance

Source

pub fn memory_usage(&self) -> usize

Get current memory usage

Source

pub fn memory_limit(&self) -> usize

Get maximum memory limit

Source

fn check_memory_limit(&self, additional_bytes: usize) -> Result<()>

Check if memory allocation is allowed

Source

fn add_memory_usage(&self, bytes: usize)

Add to memory usage counter

Source

fn subtract_memory_usage(&self, bytes: usize)

Subtract from memory usage counter

Source

fn find_node(&self, path: &str) -> Option<TmpNode>

Find a node by path

Source

fn find_node_mut<F, R>(&self, path: &str, f: F) -> Option<R>
where F: FnOnce(&mut TmpNode) -> R,

Find a mutable reference to a node by path

Source

fn find_parent_mut<F, R>(&self, path: &str, f: F) -> Result<R>
where F: FnOnce(&mut TmpNode, &str) -> R,

Find parent node and return mutable reference

Source

fn normalize_path(&self, path: &str) -> String

Normalize path for consistent handling

Trait Implementations§

Source§

impl FileOperations for TmpFS

Source§

fn open(&self, path: &str, _flags: u32) -> Result<Arc<dyn FileHandle>>

Open a file
Source§

fn read_dir(&self, path: &str) -> Result<Vec<DirectoryEntry>>

Read directory entries
Source§

fn create_file(&self, path: &str, file_type: FileType) -> Result<()>

Create a file with the specified type. Read more
Source§

fn create_dir(&self, path: &str) -> Result<()>

Create a directory
Source§

fn remove(&self, path: &str) -> Result<()>

Remove a file/directory
Source§

fn metadata(&self, path: &str) -> Result<FileMetadata>

Get the metadata
Source§

fn root_dir(&self) -> Result<Directory<'_>>

Get the root directory of the file system
Source§

impl FileSystem for TmpFS

Source§

fn mount(&mut self, mount_point: &str) -> Result<()>

Mount operation
Source§

fn unmount(&mut self) -> Result<()>

Unmount operation
Source§

fn name(&self) -> &str

Get the name of the file system

Auto Trait Implementations§

§

impl !Freeze for TmpFS

§

impl !RefUnwindSafe for TmpFS

§

impl Send for TmpFS

§

impl Sync for TmpFS

§

impl Unpin for TmpFS

§

impl UnwindSafe for TmpFS

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<T> VirtualFileSystem for T