Struct libpna::EntryBuilder

source ·
pub struct EntryBuilder { /* private fields */ }
Expand description

A builder for creating a new RegularEntry.

Implementations§

source§

impl EntryBuilder

source

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.

source

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.

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();

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();
source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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

source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Writes a buffer into this writer, returning how many bytes were written. Read more
source§

fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. 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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V