uuencoding-multi
Multi-part UUencoded Usenet/email post reassembly.
Multi-part UUencoding was the standard way to post binary files to Usenet before MIME.
A large file was split into numbered parts, each posted as a separate message with a
subject line like filename.tar.gz (03/17). This crate reassembles those parts.
Depends on the uuencoding crate for decoding
individual parts.
Features
- Parse 5 real-world subject line formats to extract part number and total
- Accumulate parts via
PartCollectionwith gap detection andis_complete()check - Best-effort TOC (table-of-contents) parsing for part-0 summary posts
reassemble()— decode each part and concatenate into the original file bytes- Partial reassembly when parts are missing (
is_truncatedflag,missing_partslist) - No panics on any input
- No unsafe code
- MSRV: 1.75
Quick start
use ;
// Step 1: parse subject lines to identify part number and grouping key
let sp = parse_subject.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
// Step 2: collect parts (body_bytes is the raw UU-encoded message body,
// extracted from each message by the caller before passing it here)
let part1_bytes: = todo!;
let part2_bytes: = todo!;
let part3_bytes: = todo!;
let mut coll = with_total;
coll.add.unwrap;
coll.add.unwrap;
coll.add.unwrap;
// Step 3: reassemble when complete
if coll.is_complete
Subject line formats supported
| Format | Example |
|---|---|
| Parenthesized fraction | filename.tar.gz (03/17) |
| Bracketed fraction | filename.tar.gz [03/17] |
| English Part N/M | filename.zip Part 3/17 |
| English Part N of M | filename.zip Part 03 of 17 |
| Dash-separated | filename.zip - 03/17 |
Re: and Fwd: prefixes are stripped before matching. yEnc subjects return None
(distinct encoding, out of scope for this crate).
Partial reassembly
When parts are missing, reassemble() still returns Ok rather than an error:
let file = reassemble.unwrap;
if file.is_truncated
Warning — truncated data is not a file. When
is_truncatedistrue,file.datacontains only the decoded bytes of the present parts concatenated in order. This is not a contiguous region of the original file: the bytes from missing parts are simply absent. Do not write this data to disk as a complete file — it will be corrupt and may silently produce incorrect output. Wait untilcoll.is_complete()returnstruebefore callingreassemble()if you need a usable result.
Error types
Security
Reassembled data is raw bytes which may be a compressed archive. Any decompression
is the caller's responsibility and must be independently guarded against decompression
bombs. This crate does not decompress.
The filename field of ReassembledFile comes from the email subject line or the
UU begin line and is not sanitised. Real-world UU archives have been observed
with filenames containing ../ sequences. Sanitise the filename before using it
as a filesystem path to prevent directory traversal attacks (e.g. reject names
containing /, \, or .. path components, and resolve the final path against
an allowed base directory).
License
MIT OR Apache-2.0