Struct DevNode

Source
pub struct DevNode {
    name: String,
    file_type: FileType,
    file_id: u64,
    children: RwLock<BTreeMap<String, Arc<DevNode>>>,
    filesystem: RwLock<Option<Weak<dyn FileSystemOperations>>>,
}
Expand description

A node in the DevFS filesystem

Fields§

§name: String

Node name

§file_type: FileType

File type

§file_id: u64

File ID

§children: RwLock<BTreeMap<String, Arc<DevNode>>>

Child nodes (for directories)

§filesystem: RwLock<Option<Weak<dyn FileSystemOperations>>>

Reference to filesystem

Implementations§

Source§

impl DevNode

Source

pub fn new_directory(name: String) -> Self

Create a new directory node

Source

pub fn new_device_file(name: String, file_type: FileType, file_id: u64) -> Self

Create a new device file node

Source

pub fn set_filesystem(&self, fs: Weak<dyn FileSystemOperations>)

Set filesystem reference

Source

pub fn add_child( &self, name: String, child: Arc<DevNode>, ) -> Result<(), FileSystemError>

Add a child node

Source

pub fn get_child(&self, name: &str) -> Option<Arc<DevNode>>

Get a child by name

Source

pub fn clear_children(&self)

Clear all children (for dynamic updates)

Source

pub fn readdir(&self) -> Result<Vec<DirectoryEntryInternal>, FileSystemError>

Read directory contents

Source

pub fn open(&self) -> Result<Arc<dyn FileObject>, FileSystemError>

Open the node as a file object

Trait Implementations§

Source§

impl Clone for DevNode

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl VfsNode for DevNode

Source§

fn id(&self) -> u64

Returns the unique identifier in the filesystem
Source§

fn metadata(&self) -> Result<FileMetadata, FileSystemError>

Get metadata for this node
Source§

fn filesystem(&self) -> Option<Weak<dyn FileSystemOperations>>

Returns a (Weak) reference to the filesystem this node belongs to
Source§

fn as_any(&self) -> &dyn Any

Helper for downcasting
Source§

fn file_type(&self) -> Result<FileType, FileSystemError>

Get the file type of this node
Source§

fn is_directory(&self) -> Result<bool, FileSystemError>

Returns true if this node is a directory
Returns true if this node is a symbolic link
Read the target of a symbolic link (returns error if not a symlink)

Auto Trait Implementations§

§

impl !Freeze for DevNode

§

impl !RefUnwindSafe for DevNode

§

impl Send for DevNode

§

impl Sync for DevNode

§

impl Unpin for DevNode

§

impl !UnwindSafe for DevNode

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> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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.