pub enum FileData {
Bytes(Vec<u8>),
Path(PathBuf),
}Expand description
File content — either in-memory bytes or a path on disk.
Small outputs (images, CSVs) use Bytes. Files on disk (CLI argument
files, file-collect results, shell-run file-mode outputs) use Path
to avoid reading multi-GB files into memory. A Path may be the user’s
own file: write it out with copy_to(); write_to() moves it.
Variants§
Bytes(Vec<u8>)
In-memory file content (images, CSVs, small outputs).
Path(PathBuf)
Reference to a file on disk (CLI inputs, collected files, shell outputs).
The file is NOT read into memory until into_bytes() is called.
Implementations§
Source§impl FileData
impl FileData
Sourcepub fn write_to(&self, dest: &Path) -> Result<(), Error>
pub fn write_to(&self, dest: &Path) -> Result<(), Error>
Move or write file content to a destination path.
Path variant attempts rename() first (O(1) on same filesystem),
falling back to copy+delete for cross-device moves.
Bytes variant writes data directly.
Sourcepub fn len(&self) -> Result<u64, Error>
pub fn len(&self) -> Result<u64, Error>
Byte length without loading into memory.
Bytes returns the vec length. Path reads file metadata.
Sourcepub fn copy_to(&self, dest: &Path) -> Result<(), Error>
pub fn copy_to(&self, dest: &Path) -> Result<(), Error>
Copy file content to a destination path, preserving the source.
Bytes writes data directly. Path copies the file on disk.
Unlike write_to(), the source file is never removed.