Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Expand description

The metadata builder.

See module level documentations.

Implementations§

Source§

impl Builder

Source

pub fn new(root_meta: &InodeMetadata) -> Self

Create a builder with default configurations.

Source

pub fn new_with_config(config: &Config, root_meta: &InodeMetadata) -> Self

Create a builder with custom configurations.

Source

pub fn block_size(&self) -> NonZero<u32>

Get the configured block size.

Source

pub fn root(&self) -> DirId

Get the implicitly created root directory.

Source

pub fn put_dir( &mut self, parent: DirId, name: &str, meta: &InodeMetadata, ) -> Result<DirId>

Add an empty directory under a directory.

§Errors

Return Err if either:

  • Inode count overflows.
  • Directory entry count overflows.
  • There is already an entry with the same name in the directory.

Add a hard link to an existing inode under a directory.

§Errors

See Builder::put_dir.

Source

pub fn put_file( &mut self, parent: DirId, name: &str, meta: &InodeMetadata, chunks: impl IntoIterator<Item = Chunk>, ) -> Result<FileId>

Add a regular file under a directory.

§Panics

Panics if any chunk has a offset exceeding Config::block_size.

§Errors

See Builder::put_dir.

Add a symbolic link (symlink) under a directory.

§Errors

See Builder::put_dir.

Source

pub fn put_block_device( &mut self, parent: DirId, name: &str, meta: &InodeMetadata, device_id: u64, ) -> Result<LinkableInodeId>

Add a block device inode under a directory.

§Errors

See Builder::put_dir.

Source

pub fn put_char_device( &mut self, parent: DirId, name: &str, meta: &InodeMetadata, device_id: u64, ) -> Result<LinkableInodeId>

Add a character device inode under a directory.

§Errors

See Builder::put_dir.

Source

pub fn put_fifo( &mut self, parent: DirId, name: &str, meta: &InodeMetadata, ) -> Result<LinkableInodeId>

Add a FIFO (named pipe) inode under a directory.

§Errors

See Builder::put_dir.

Source

pub fn put_socket( &mut self, parent: DirId, name: &str, meta: &InodeMetadata, ) -> Result<LinkableInodeId>

Add a socket inode under a directory.

§Errors

See Builder::put_dir.

Source

pub fn finish(self) -> Result<Metadata>

Finalize and construct the result Metadata.

§Errors

Returns Err if the hierarchy is invalid, or exceeds certain limitations, including and not limited to:

Trait Implementations§

Source§

impl Debug for Builder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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.