Struct axfs_devfs::RandomDev

source ·
pub struct RandomDev(/* private fields */);
Expand description

A random device behaves like /dev/random or /dev/urandom.

It always returns a chunk of random bytes when read, and all writes are discarded.

TODO: update entropy pool with data written.

Trait Implementations§

source§

impl Default for RandomDev

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl VfsNodeOps for RandomDev

source§

fn get_attr(&self) -> VfsResult<VfsNodeAttr>

Get the attributes of the node.
source§

fn read_at(&self, _offset: u64, buf: &mut [u8]) -> VfsResult<usize>

Read data from the file at the given offset.
source§

fn write_at(&self, _offset: u64, buf: &[u8]) -> VfsResult<usize>

Write data to the file at the given offset.
source§

fn truncate(&self, _size: u64) -> VfsResult

Truncate the file to the given size.
source§

fn lookup(self: Arc<Self>, _path: &str) -> VfsResult<VfsNodeRef>

Lookup the node with given path in the directory. Read more
source§

fn create(&self, _path: &str, _ty: VfsNodeType) -> VfsResult

Create a new node with the given path in the directory Read more
source§

fn remove(&self, _path: &str) -> VfsResult

Remove the node with the given path in the directory.
source§

fn read_dir( &self, _start_idx: usize, _dirents: &mut [VfsDirEntry] ) -> VfsResult<usize>

Read directory entries into dirents, starting from start_idx.
source§

fn as_any(&self) -> &dyn Any

Convert &self to &dyn Any that can use Any::downcast_ref.
source§

fn open(&self) -> Result<(), AxError>

Do something when the node is opened.
source§

fn release(&self) -> Result<(), AxError>

Do something when the node is closed.
source§

fn fsync(&self) -> Result<(), AxError>

Flush the file, synchronize the data to disk.
source§

fn parent(&self) -> Option<Arc<dyn VfsNodeOps>>

Get the parent directory of this directory. Read more
source§

fn rename(&self, _src_path: &str, _dst_path: &str) -> Result<(), AxError>

Renames or moves existing file or directory.

Auto Trait Implementations§

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>,

§

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>,

§

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.