pub struct OdcBuilder<W: Write + Sized> { /* private fields */ }
Expand description

Iteratively create a cpio archive using the Portable ASCII format.

cpio archives logically consist of 2-tuples of (file header, data), so data can be streamed by iteratively feeding new entries to write.

cpio archives contain a special file header denoting the end of the archive. This is emitted by calling Self::finish. So consumers should always call this method when done writing new files.

By default, missing parent directories are automatically emitted when writing files. Instances track which directories have been emitted. Upon encountering a file path in a directory that has not yet been emitted, a directory entry will be emitted. This behavior can be disabled by calling Self::auto_write_dirs.

Implementations

Construct a new instance which will write data to a writer.

Set the default file mode to use for files.

Set the default file mode to use for directories.

Set the default user ID (UID).

Set the default group ID (GID).

Set the default modified time.

Set the behavior for auto writing directory entries.

Obtain a header record representing the next header in the archive.

The header has fields set to default values. Callers should likely update at least the name and possibly the file size and mode.

This will increment the inode sequence number when called.

Append a raw header and corresponding file data to the writer.

The writer and data are written as-is.

Only simple validation that the data length matches the length advertised in the header is performed.

Automatic directory emission is not processed in this mode.

Append a raw header and corresponding data from a reader to the writer.

The header’s file size must match the length of data available in the reader or errors could occur. This method will copy all data available in the reader to the output stream. If the number of bytes written does not match what is reported by the header, the cpio archive stream is effectively corrupted and an error is returned.

Write a regular file to the cpio archive with provided file data and file mode.

Write a regular file to the cpio archive.

This takes the relative path in the archive and the filesystem path of the file to write. It resolves header metadata automatically given filesystem attributes. However, the UID, GID, and mtime defaults specified on this builder are used so archive construction is more deterministic.

Append a FileManifest to the archive.

Finish writing the archive.

This will emit a special header denoting the end of archive.

Failure to call this method will result in a malformed cpio archive. Readers may or may not handle the missing trailer correctly.

Consume self and return the original writer this instance was constructed from.

This will automatically finish the archive if needed.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.