Skip to main content

read_within

Function read_within 

Source
pub fn read_within(
    bytes: &[u8],
    max_unpacked_bytes: u64,
) -> Result<Opened<Hprz>, FormatError>
Expand description

Reads a container, decompressing at most max_unpacked_bytes out of it, and says which version its design was written in.

The design is read as a .hpr is (read_json). A folder’s own entry, which some zip tools write, holds nothing and is passed over; every other entry is an attachment, held to the rules write holds it to. Every name is checked before anything is decompressed.

§Errors

FormatError::Container when the bytes are not a zip archive, an entry can’t be read, the central directory holds more entries than the zip reader keeps (two of one name), an entry is a symbolic link or its name isn’t marked as UTF-8, an attachment’s name is refused, the archive would decompress to more than max_unpacked_bytes, or it holds no DESIGN_ENTRY or the design isn’t UTF-8; and what read_json refuses in the design.