Struct libpna::EntryBuilder
source · pub struct EntryBuilder { /* private fields */ }Expand description
A builder for creating a new RegularEntry.
Implementations§
source§impl EntryBuilder
impl EntryBuilder
sourcepub const fn new_dir(name: EntryName) -> Self
pub const fn new_dir(name: EntryName) -> Self
Creates a new directory with the given name.
§Arguments
name- The name of the entry to create.
§Returns
A new EntryBuilder.
sourcepub fn new_file(name: EntryName, option: WriteOptions) -> Result<Self>
pub fn new_file(name: EntryName, option: WriteOptions) -> Result<Self>
Creates a new file with the given name and write options.
§Arguments
name- The name of the entry to create.option- The options for writing the entry.
§Returns
A Result containing the new EntryBuilder, or an I/O error if creation fails.
sourcepub fn new_symbolic_link(
name: EntryName,
source: EntryReference,
) -> Result<Self>
pub fn new_symbolic_link( name: EntryName, source: EntryReference, ) -> Result<Self>
Creates a new symbolic link with the given name and link.
§Arguments
name- The name of the entry to create.link- The name of the entry reference.
§Returns
A new EntryBuilder.
§Examples
use libpna::{EntryBuilder, EntryName, EntryReference};
let builder = EntryBuilder::new_symbolic_link(
EntryName::try_from("path/of/target").unwrap(),
EntryReference::try_from("path/of/source").unwrap(),
)
.unwrap();
let entry = builder.build().unwrap();sourcepub fn new_hard_link(name: EntryName, source: EntryReference) -> Result<Self>
pub fn new_hard_link(name: EntryName, source: EntryReference) -> Result<Self>
Creates a new hard link with the given name and link.
§Arguments
name- The name of the entry to create.link- The name of the entry reference.
§Returns
A new EntryBuilder.
§Examples
use libpna::{EntryBuilder, EntryName, EntryReference};
let builder = EntryBuilder::new_hard_link(
EntryName::try_from("path/of/target").unwrap(),
EntryReference::try_from("path/of/source").unwrap(),
)
.unwrap();
let entry = builder.build().unwrap();sourcepub fn created(&mut self, since_unix_epoch: Duration) -> &mut Self
pub fn created(&mut self, since_unix_epoch: Duration) -> &mut Self
Sets the creation timestamp of the entry.
§Arguments
since_unix_epoch- The duration since the Unix epoch to set the creation timestamp to.
§Returns
A mutable reference to the EntryBuilder with the creation timestamp set.
sourcepub fn modified(&mut self, since_unix_epoch: Duration) -> &mut Self
pub fn modified(&mut self, since_unix_epoch: Duration) -> &mut Self
Sets the last modified timestamp of the entry.
§Arguments
since_unix_epoch- The duration since the Unix epoch to set the last modified timestamp to.
§Returns
A mutable reference to the EntryBuilder with the last modified timestamp set.
sourcepub fn accessed(&mut self, since_unix_epoch: Duration) -> &mut Self
pub fn accessed(&mut self, since_unix_epoch: Duration) -> &mut Self
Sets the last accessed timestamp of the entry.
§Arguments
since_unix_epoch- The duration since the Unix epoch to set the last accessed timestamp to.
§Returns
A mutable reference to the EntryBuilder with the last modified timestamp set.
sourcepub fn permission(&mut self, permission: Permission) -> &mut Self
pub fn permission(&mut self, permission: Permission) -> &mut Self
Sets the permission of the entry to the given owner, group, and permissions.
§Arguments
permission- A Permission struct containing the owner, group, and permissions to set for the entry.
§Returns
A mutable reference to the EntryBuilder with the permission set.
sourcepub fn file_size(&mut self, store: bool) -> &mut Self
pub fn file_size(&mut self, store: bool) -> &mut Self
Sets retention of raw file size data for entry.
§Arguments
store- If true retention data of raw file size for entry, otherwise not.
§Returns
A mutable reference to the EntryBuilder with the store set.
sourcepub fn add_xattr(&mut self, xattr: ExtendedAttribute) -> &mut Self
pub fn add_xattr(&mut self, xattr: ExtendedAttribute) -> &mut Self
Adds ExtendedAttribute to the entry.
§Arguments
xattr- The extended attribute.
§Returns
A mutable reference to the EntryBuilder with the creation timestamp set.
sourcepub fn add_extra_chunk<T: Into<RawChunk>>(&mut self, chunk: T) -> &mut Self
pub fn add_extra_chunk<T: Into<RawChunk>>(&mut self, chunk: T) -> &mut Self
Adds extra chunk to the entry.
§Arguments
chunk- The extra chunk.
§Returns
A mutable reference to the EntryBuilder with the creation timestamp set.
sourcepub fn build(self) -> Result<RegularEntry>
pub fn build(self) -> Result<RegularEntry>
Builds the entry and returns a Result containing the new RegularEntry.
§Returns
A Result containing the new RegularEntry, or an I/O error if the build fails.
Trait Implementations§
source§impl Write for EntryBuilder
impl Write for EntryBuilder
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)