Skip to main content

NeedEntries

Struct NeedEntries 

Source
pub struct NeedEntries<W: Read + Write + Seek> { /* private fields */ }
Available on crate feature writer only.
Expand description

Preparation step for writing phar entries.

For performance reasons, users need to first provide all file metadata before providing all file contents. Consider using build_from_* if the data source is located on the filesystem.

Implementations§

Source§

impl<W: Read + Write + Seek> NeedEntries<W>

Source

pub fn entry( &mut self, name: impl Read, metadata: impl Read, timestamp: SystemTime, mode: u32, compression: Compression, ) -> Result<()>

Adds an entry to the phar.

The file contents shall be later passed with the Contents::feed method in the same order.

Source

pub fn contents(self) -> Result<Contents<W>>

Starts writing the contents section of the phar.

Users should call feed on the returned Contents value with the file contents in the exact same order as entries declared with entry.

Source

pub fn build_from_directory( self, path: &Path, compression: Compression, ) -> Result<()>

Builds the phar from a directory on the filesystem.

Source

pub fn build_from_path_iter<S, P, I>( self, iter: impl Fn() -> I, compression: Compression, ) -> Result<()>
where I: Iterator<Item = Result<(S, P)>>, S: AsRef<OsStr>, P: AsRef<Path>,

Builds the phar from an iterator of file paths.

The iterator parameter yields (S, P) pairs, where each S is an OsStr representing the path inside the archive and each P is a Path that resolves to the actual file to include (at least relative to the current working directory).

Auto Trait Implementations§

§

impl<W> Freeze for NeedEntries<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for NeedEntries<W>
where W: RefUnwindSafe,

§

impl<W> Send for NeedEntries<W>
where W: Send,

§

impl<W> Sync for NeedEntries<W>
where W: Sync,

§

impl<W> Unpin for NeedEntries<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for NeedEntries<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for NeedEntries<W>
where W: UnwindSafe,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.