Skip to main content

rust-multipart

This package provides a Sans-IO parser for RFC 7578 multipart/form-data. It is heavily inspired by defnull/multipart.

Installation

pip install rust-multipart

Usage

from rust_multipart import MultipartParser, PartBegin, PartData, PartEnd

parser = MultipartParser(boundary=b"boundary")
events = parser.feed(b'--boundary\r\nContent-Disposition: form-data; name="user"\r\n\r\nPotato\r\n--boundary--\r\n')
parser.finish()

begin, data, end = events
assert isinstance(begin, PartBegin)
assert begin.headers == [(b"Content-Disposition", b'form-data; name="user"')]
assert isinstance(data, PartData)
assert data.data == b"Potato"
assert isinstance(end, PartEnd)

You can call feed() repeatedly with partial input. Each call returns the batch of events produced by that chunk: PartBegin carries the ordered raw byte headers, PartData carries a body chunk, and PartEnd closes the part. The parser never accumulates part bodies, so memory stays bounded regardless of upload size. Call finish() once the input ends: it raises ValueError if the closing boundary was never received.

Use parse_options_header() to parse header values like Content-Disposition:

from rust_multipart import parse_options_header

value, parameters = parse_options_header('form-data; name="user"')
assert value == "form-data"
assert parameters == {"name": "user"}

Development

uv sync --group dev
uv run maturin develop
scripts/check

scripts/check runs formatting, linting, type checking, Python coverage, native Rust coverage, and the high-level test suite. Both Python and Rust line coverage must remain at 100%.

Run the CodSpeed benchmarks locally with:

uv run pytest benchmarks --codspeed

License

This project is licensed under the MIT License.

Metadata

Release files for rust-multipart 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rust-multipart 0.0.1
File Size Uploaded
rust_multipart-0.0.1.tar.gz 77.9 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for rust-multipart 0.0.1
File
rust_multipart-0.0.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
rust_multipart-0.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
rust_multipart-0.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
rust_multipart-0.0.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
rust_multipart-0.0.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 1.3 MB

Release files / rust_multipart-0.0.1.tar.gz

Download URL rust_multipart-0.0.1.tar.gz
Size 77.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0d2227e1d37049b7c78fefe49e6ac19f4e1e4279f85c5b6f8dafe4f4e108cbd8
BLAKE2b-256 checksum
How to use checksums
f9117b478500c28e817a5c516bd5056dbcf182f156531d77d4dbd55776666cca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rust_multipart-0.0.1-cp310-abi3-win_amd64.whl

Download URL rust_multipart-0.0.1-cp310-abi3-win_amd64.whl
Size 153.6 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e90ea971e1bce0a86557846cd15cfaf28e4eacab3d180ff4111a7d9237cff8cd
BLAKE2b-256 checksum
How to use checksums
b88166465aa937081e863e4d7806dee30da05e7239071d89ddc801c34a23e926
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rust_multipart-0.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rust_multipart-0.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 270.9 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
bc47f7a1d15b4edaf464294c789c880220584f10dd7110a3c744b13e26569cd5
BLAKE2b-256 checksum
How to use checksums
08c100ccacc39501f3f4579c61db62aaece6bad568881164f4a9ea139d904789
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rust_multipart-0.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL rust_multipart-0.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 265.2 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
a2f135a058932993142ebb67101e27d96beadca0d740fc3a04e16bde169c3d9d
BLAKE2b-256 checksum
How to use checksums
1cc24cf36c8d5108852feeeda441e1b98467a8325230f3c9cbfcd5492b01abbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rust_multipart-0.0.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL rust_multipart-0.0.1-cp310-abi3-macosx_11_0_arm64.whl
Size 243.7 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a2c3f5f362b7170ebc13117cb3a1cd71fb96699d5658654a258c6d466a266696
BLAKE2b-256 checksum
How to use checksums
4fc366d4e349a4ad905d4fb7f7de5c3e71710309f09a8fc907c7f44905b9ed27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rust_multipart-0.0.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL rust_multipart-0.0.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 253.5 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
60457a7b46f3568ad38274ab6da5250a1937a17d3a5d3ff2151d708de6f2aa08
BLAKE2b-256 checksum
How to use checksums
a11fcc4b7cfaa6ed0abfe555ab5600004032551e144cd06ef13f38ec2c519deb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.0.2

6 release files

This release

0.0.1 This release

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page