1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/// Archive format conversion (transcoding)
///
/// Provides functionality to convert between different archive formats
/// by decoding from one format and encoding to another.
///
/// This module is only available when both `encode` and `decode` features
/// are enabled, plus the `convert` feature.
use crate::;
/// Convert an archive from one format to another
///
/// Decodes the input archive and re-encodes the extracted files into
/// the target format. This is more efficient than extracting to disk
/// and re-compressing, as all operations happen in memory.
///
/// # Arguments
/// * `input` - Raw bytes of the input archive
/// * `input_fmt` - The format of the input archive
/// * `output_fmt` - The desired output format
///
/// # Returns
/// * `Ok(Vec<u8>)` - The converted archive data
/// * `Err(ArchiveError)` - If decoding or encoding fails
///
/// # Example
/// ```no_run
/// use easy_archive::{Fmt, convert::convert_archive};
///
/// let tar_gz_data = std::fs::read("archive.tar.gz")?;
/// let zip_data = convert_archive(tar_gz_data, Fmt::TarGz, Fmt::Zip)?;
/// std::fs::write("archive.zip", zip_data)?;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
/// Convert an archive from one format to another by reading from a file
/// and writing the result to another file.
///
/// # Arguments
/// * `input_path` - Path to the input archive file
/// * `output_path` - Path for the output archive file
/// * `input_fmt` - The format of the input archive
/// * `output_fmt` - The desired output format
///
/// # Returns
/// * `Ok(())` - If conversion succeeds
/// * `Err(ArchiveError)` - If reading, decoding, encoding, or writing fails
///
/// # Example
/// ```no_run
/// use easy_archive::{Fmt, convert::convert_archive_file};
///
/// convert_archive_file("archive.tar.gz", "archive.zip", Fmt::TarGz, Fmt::Zip)?;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```