Struct CpioNode

Source
pub struct CpioNode {
    name: String,
    file_type: FileType,
    content: Vec<u8>,
    children: RwLock<BTreeMap<String, Arc<CpioNode>>>,
    filesystem: RwLock<Option<Arc<CpioFS>>>,
    file_id: usize,
    parent: RwLock<Option<Weak<CpioNode>>>,
}
Expand description

A single node in the CPIO filesystem

Fields§

§name: String

File name

§file_type: FileType

File type

§content: Vec<u8>

File content (for regular files)

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

Child nodes (for directories)

§filesystem: RwLock<Option<Arc<CpioFS>>>

Reference to filesystem

§file_id: usize

File ID

§parent: RwLock<Option<Weak<CpioNode>>>

Parent node (weak reference)

Implementations§

Source§

impl CpioNode

Source

pub fn new( name: String, file_type: FileType, content: Vec<u8>, file_id: usize, ) -> Arc<Self>

Create a new CPIO node

Source

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

Add a child to this directory node

Source

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

Get a child by name

Source

pub fn parent_file_id(&self) -> Option<u64>

Source

pub fn from_vfsnode_arc(node: &Arc<dyn VfsNode>) -> Option<Arc<CpioNode>>

Helper to convert from Arc to Arc

Trait Implementations§

Source§

impl VfsNode for CpioNode

Source§

fn id(&self) -> u64

Returns the unique identifier in the filesystem
Source§

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

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

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

Get metadata for this node
Source§

fn as_any(&self) -> &dyn Any

Helper for downcasting
Read the target of a symbolic link (returns error if not a symlink)
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

Auto Trait Implementations§

§

impl !Freeze for CpioNode

§

impl !RefUnwindSafe for CpioNode

§

impl Send for CpioNode

§

impl Sync for CpioNode

§

impl Unpin for CpioNode

§

impl !UnwindSafe for CpioNode

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.