Skip to main content

ReassembledFile

Struct ReassembledFile 

Source
pub struct ReassembledFile {
    pub filename: String,
    pub mode: u32,
    pub data: Vec<u8>,
    pub is_truncated: bool,
    pub missing_parts: Vec<u32>,
}
Expand description

A successfully reassembled multi-part UU-encoded file.

Returned by reassemble. The data field holds the decoded binary payload; callers should inspect is_truncated before trusting the result.

§Security note

data may contain a compressed archive. This crate never decompresses the output. Apply independent size and resource limits before decompressing to protect against decompression-bomb attacks.

Fields§

§filename: String

Filename extracted from the begin line of the first UU part.

Security — path traversal: the filename comes directly from the email or Usenet message and is not sanitised. Real-world UU archives have been observed with filenames containing ../ sequences. Sanitise this value before using it as a filesystem path to prevent directory traversal attacks (e.g. reject names containing /, \, or .. components, and resolve the final path against an allowed base directory).

§mode: u32

Unix permission mode (e.g. 0o644) from the begin line of the first part. Subsequent parts may specify different modes; only the first part’s value is used.

§data: Vec<u8>

Decoded binary payload.

When is_truncated is false, this is the complete decoded file content, formed by concatenating the decoded output of every part in ascending part_number order.

§When is_truncated is true

data contains only the decoded bytes of the parts that were present, concatenated in ascending part-number order. This is not a contiguous region of the reconstructed file: the bytes belonging to the absent parts are simply missing from the middle (or start, or end). The resulting byte sequence does not correspond to any valid file offset range.

Do not write truncated data to disk as if it were a complete file. The bytes are provided for diagnostic inspection only (e.g. logging, partial-content display). To obtain a usable file, wait until is_complete() returns true before calling reassemble.

§is_truncated: bool

true when one or more parts were absent from the collection, or when any individual part’s UU body was missing its end line. The data is likely corrupt in this case.

To distinguish the two truncation causes:

  • is_truncated && !missing_parts.is_empty() — gap in the collection.
  • is_truncated && missing_parts.is_empty() — all parts were present but at least one part’s UU body was itself truncated (missing end).
§missing_parts: Vec<u32>

Part numbers in 1..=total that were absent from the collection, in ascending order. Empty when the collection was complete.

Trait Implementations§

Source§

impl Debug for ReassembledFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ReassembledFile

Source§

fn eq(&self, other: &ReassembledFile) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ReassembledFile

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.