Skip to main content

Encode

Trait Encode 

Source
pub trait Encode {
    // Required method
    fn encode(files: Vec<File>) -> Result<Vec<u8>>;
}
Expand description

Trait for encoding files into archives

Implementors of this trait can encode a list of files into archive format.

This trait is only available when the encode feature is enabled.

Required Methods§

Source

fn encode(files: Vec<File>) -> Result<Vec<u8>>

Encode files into an archive

§Arguments
  • files - The list of files to include in the archive
§Returns
  • Ok(Vec<u8>) - The encoded archive data on success
  • Err(ArchiveError) - If encoding fails or duplicate files are detected
§Example
use easy_archive::{Encode, File, archive::tar::Tar};

let files = vec![
    File {
        path: "hello.txt".to_string(),
        buffer: b"Hello, world!".to_vec(),
        ..Default::default()
    }
];
let archive = Tar::encode(files)?;

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§