pub struct Builder { /* private fields */ }
Expand description
The metadata builder.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn new(root_meta: &InodeMetadata) -> Self
pub fn new(root_meta: &InodeMetadata) -> Self
Create a builder with default configurations.
Sourcepub fn new_with_config(config: &Config, root_meta: &InodeMetadata) -> Self
pub fn new_with_config(config: &Config, root_meta: &InodeMetadata) -> Self
Create a builder with custom configurations.
Sourcepub fn block_size(&self) -> NonZero<u32>
pub fn block_size(&self) -> NonZero<u32>
Get the configured block size.
Sourcepub fn put_dir(
&mut self,
parent: DirId,
name: &str,
meta: &InodeMetadata,
) -> Result<DirId>
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.
Sourcepub fn put_hard_link(
&mut self,
parent: DirId,
name: &str,
inode: impl Into<LinkableInodeId>,
) -> Result<()>
pub fn put_hard_link( &mut self, parent: DirId, name: &str, inode: impl Into<LinkableInodeId>, ) -> Result<()>
Sourcepub fn put_file(
&mut self,
parent: DirId,
name: &str,
meta: &InodeMetadata,
chunks: impl IntoIterator<Item = Chunk>,
) -> Result<FileId>
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
.
Sourcepub fn put_symlink(
&mut self,
parent: DirId,
name: &str,
meta: &InodeMetadata,
target: &str,
) -> Result<LinkableInodeId>
pub fn put_symlink( &mut self, parent: DirId, name: &str, meta: &InodeMetadata, target: &str, ) -> Result<LinkableInodeId>
Sourcepub fn put_block_device(
&mut self,
parent: DirId,
name: &str,
meta: &InodeMetadata,
device_id: u64,
) -> Result<LinkableInodeId>
pub fn put_block_device( &mut self, parent: DirId, name: &str, meta: &InodeMetadata, device_id: u64, ) -> Result<LinkableInodeId>
Sourcepub fn put_char_device(
&mut self,
parent: DirId,
name: &str,
meta: &InodeMetadata,
device_id: u64,
) -> Result<LinkableInodeId>
pub fn put_char_device( &mut self, parent: DirId, name: &str, meta: &InodeMetadata, device_id: u64, ) -> Result<LinkableInodeId>
Sourcepub fn put_fifo(
&mut self,
parent: DirId,
name: &str,
meta: &InodeMetadata,
) -> Result<LinkableInodeId>
pub fn put_fifo( &mut self, parent: DirId, name: &str, meta: &InodeMetadata, ) -> Result<LinkableInodeId>
Sourcepub fn put_socket(
&mut self,
parent: DirId,
name: &str,
meta: &InodeMetadata,
) -> Result<LinkableInodeId>
pub fn put_socket( &mut self, parent: DirId, name: &str, meta: &InodeMetadata, ) -> Result<LinkableInodeId>
Sourcepub fn finish(self) -> Result<Metadata>
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:
- Duplicated entry names in a directory.
- Any (intermediate) low-level structures exceeds 2³² bytes. See module level documentations.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more