Skip to main content

P4Rust

Safe Rust bindings to the Perforce 2026.1 C++ API. Precompiled resources support Windows MSVC, Linux GNU, and macOS on x64 and ARM64. Consumers compile only Rust.

Published Packages

Language Link Compatibility
Rust crates.io Windows MSVC, Linux GNU (glibc 2.28+), macOS 12+; x64 and ARM64. Consumers compile only Rust.
Python PyPI CPython 3.9+ (cp39-abi3), including free-threaded CPython 3.15+ (cp315-abi3.abi3t); Windows, Linux (glibc 2.28+), macOS 12+; x64 and ARM64.

Rust

[dependencies]
p4rust = "0.1"
use p4rust::{Client, Config, Event, Result, ResultExt};

// Stream file records, progress, and command completion.
fn main() -> Result<()> {
    let client = Client::new(Config::new("localhost:1666", "user", "workspace"))
        .context("Failed to create client")?;
    let events = client
        .command("sync")
        .args(["D:/workspace/file.txt"])
        .run()
        .context("Failed to start sync")?;

    for event in events {
        match event.context("Failed to sync file")? {
            Event::Record(record) => {
                for (key, value) in record.fields() {
                    println!("{key}: {value}");
                }
            }
            Event::Progress(progress) => {
                println!(
                    "{:?}: {}/{}",
                    progress.kind, progress.current, progress.total
                );
            }
            Event::Message(message) | Event::HandleError(message) => {
                println!("{}", message.text);
            }
            event => println!("{event:#?}"),
        }
    }
    Ok(())
}

run() streams events; collect_output() collects results. Configure input, timeout, and cancellation on the builder.

Use FastReconcile for parallel local processing.

let events = client
    .command("reconcile")
    .args(["-n", "-m", "D:/workspace/..."])
    .reconcile_handler(
        p4rust::FastReconcile::new()
            .metadata_workers(8)
            .digest_workers(4)
            .move_workers(4),
    )
    .run()
    .context("Failed to start reconcile")?;

for event in events {
    println!("{:#?}", event.context("Failed to reconcile")?);
}

-n previews changes; -m checks timestamps before contents; -M enables move detection.

Python

Install p4rust from PyPI with pip install p4rust. Wheels support ordinary CPython 3.9+ and free-threaded CPython 3.15+ on the same six platforms. Public APIs include complete typing and preserve native message codes, bytes, progress, and completion status. The Python ZIP is also available from GitHub Releases.

from p4rust import Client, Config, RecordEvent

client = Client(Config("localhost:1666", "user", "workspace"))
events = (
    client
    .command("files")
    .args(["D:/workspace/..."])
    .timeout(30.0)
    .run()
)
with events:
    for event in events:
        if isinstance(event, RecordEvent):
            print(event.record.fields())

Use .input(form), .cancellation(token), or .reconcile_handler(FastReconcile()) before .run(). collect_output() collects the remaining stream; close() cancels a command.

Reusing a connection

Config::discover(cwd) in Rust and Config.discover(cwd) in Python resolve the SDK's environment, registry, and P4CONFIG defaults without a server connection. Discovered and explicit credentials are excluded from configuration debug output. Set password, ignore_file, or tagged on a configuration before creating its client; these settings are isolated per client and session. Use client.is_ignored(absolute_path) for the SDK's local ignore rules. Tagged and untagged clients own separate protocol connections.

client.command() opens an independent connection for each command. Use a session for sequential queries on one dedicated SDK thread:

with client.session() as session:
    with session.command("info").run() as events:
        output = events.collect_output()
    with session.command("files").args(["D:/workspace/..."]).run() as events:
        output = events.collect_output()

Rust callers use let session = client.session()?, then session.command(...) and session.close()?. A session opens its connection lazily and retains it between commands. A busy or closed session rejects new work immediately. Use independent commands or separate sessions for concurrency.

Stream cancellation, deadlines, output backpressure, and reconcile handlers remain command-local. A cancelled, failed, or disconnected native command discards its connection; a later command reconnects without replaying the failed operation. Closing a session cancels active work and requests cleanup on the owner thread without blocking the caller. Command builders and streams retain their session, and the last owner also requests cleanup when dropped.

Maintainers

xtask builds native resources and packages all six targets. GitHub Actions runs builds, Clippy, and Python typing checks, publishes changed crates.io versions and Python wheels to PyPI, and releases separate Rust and Python ZIPs.

Metadata

Release files for p4rust 0.1.18

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

Built distributions (wheels)

Table of built distributions (wheels) for p4rust 0.1.18
File Actions
p4rust-0.1.18-cp315-abi3.abi3t-win_arm64.whl CPython 3.15 abi3, abi3t Windows ARM64 Details for p4rust-0.1.18-cp315-abi3.abi3t-win_arm64.whl
p4rust-0.1.18-cp315-abi3.abi3t-win_amd64.whl CPython 3.15 abi3t, abi3 Windows x86-64 Details for p4rust-0.1.18-cp315-abi3.abi3t-win_amd64.whl
p4rust-0.1.18-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl CPython 3.15 abi3t, abi3 Linux glibc 2.28+ x86-64 Details for p4rust-0.1.18-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl
p4rust-0.1.18-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl CPython 3.15 abi3t, abi3 Linux glibc 2.28+ ARM64 Details for p4rust-0.1.18-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl
p4rust-0.1.18-cp315-abi3.abi3t-macosx_12_0_x86_64.whl CPython 3.15 abi3t, abi3 macOS 12.0+ x86-64 Details for p4rust-0.1.18-cp315-abi3.abi3t-macosx_12_0_x86_64.whl
p4rust-0.1.18-cp315-abi3.abi3t-macosx_12_0_arm64.whl CPython 3.15 abi3t, abi3 macOS 12.0+ ARM64 Details for p4rust-0.1.18-cp315-abi3.abi3t-macosx_12_0_arm64.whl
p4rust-0.1.18-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details for p4rust-0.1.18-cp39-abi3-win_arm64.whl
p4rust-0.1.18-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for p4rust-0.1.18-cp39-abi3-win_amd64.whl
p4rust-0.1.18-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details for p4rust-0.1.18-cp39-abi3-manylinux_2_28_x86_64.whl
p4rust-0.1.18-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details for p4rust-0.1.18-cp39-abi3-manylinux_2_28_aarch64.whl
p4rust-0.1.18-cp39-abi3-macosx_12_0_x86_64.whl CPython 3.9 abi3 macOS 12.0+ x86-64 Details for p4rust-0.1.18-cp39-abi3-macosx_12_0_x86_64.whl
p4rust-0.1.18-cp39-abi3-macosx_12_0_arm64.whl CPython 3.9 abi3 macOS 12.0+ ARM64 Details for p4rust-0.1.18-cp39-abi3-macosx_12_0_arm64.whl

Total release size: 43.7 MB

Release files / p4rust-0.1.18-cp315-abi3.abi3t-win_arm64.whl

Download URL p4rust-0.1.18-cp315-abi3.abi3t-win_arm64.whl
Size 3.1 MB
Tags CPython 3.15 Windows ARM64 abi3 abi3t
SHA-256 checksum
How to use checksums
abd904acaa56cfbbe906006e08329357b22d3b8475c272f7802b7044ecba3430
BLAKE2b-256 checksum
How to use checksums
9d2b3f5782ebf6d5e8c3eec5e63203c98ff2134902af813f23e29104ee167f3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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 / p4rust-0.1.18-cp315-abi3.abi3t-win_amd64.whl

Download URL p4rust-0.1.18-cp315-abi3.abi3t-win_amd64.whl
Size 3.5 MB
Tags CPython 3.15 Windows x86-64 abi3 abi3t
SHA-256 checksum
How to use checksums
7bd8053a9e3d2177b704e2996478c6f0688e22094ab423e8dc0b43db06e262a8
BLAKE2b-256 checksum
How to use checksums
4126eceafac6525e2bf6398ba81212b6b99e65180b0526f171ac80f2bbbad015
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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 / p4rust-0.1.18-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl

Download URL p4rust-0.1.18-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl
Size 4.1 MB
Tags CPython 3.15 Linux glibc 2.28+ x86-64 abi3 abi3t
SHA-256 checksum
How to use checksums
f0f779149578917ba9021ae936ae288d354924798eea6ee30006c3777f7d4b15
BLAKE2b-256 checksum
How to use checksums
4cb50d66ddfbc375e2ce3f51269028f91950415344e9dcc48083ad3ccc1334a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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 / p4rust-0.1.18-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl

Download URL p4rust-0.1.18-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl
Size 4.3 MB
Tags CPython 3.15 Linux glibc 2.28+ ARM64 abi3 abi3t
SHA-256 checksum
How to use checksums
2d885dc87ec9c91ee545018a70e91c1bfa77d4209f6fc3edbcfba445b6c4a6d3
BLAKE2b-256 checksum
How to use checksums
81d580bf4c20f804391b6b2246aecd440ba294b282f5f0c4c69b8427d0e0dabb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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 / p4rust-0.1.18-cp315-abi3.abi3t-macosx_12_0_x86_64.whl

Download URL p4rust-0.1.18-cp315-abi3.abi3t-macosx_12_0_x86_64.whl
Size 3.3 MB
Tags CPython 3.15 abi3 abi3t macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
63eb9292410625a9f8f278635fed55a02fd83cf0d5cff6e984271dfacf1727dd
BLAKE2b-256 checksum
How to use checksums
b449a9cc4570000f61f055bf30ec17e85c073086f31f64fcb6417b435bbff44b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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 / p4rust-0.1.18-cp315-abi3.abi3t-macosx_12_0_arm64.whl

Download URL p4rust-0.1.18-cp315-abi3.abi3t-macosx_12_0_arm64.whl
Size 3.6 MB
Tags CPython 3.15 abi3 abi3t macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
7734cf068c6fbb3b1bf98bab3ceb57c4537b64b8e4a3aff162a8ccd9939a0c54
BLAKE2b-256 checksum
How to use checksums
9b8dfbd4b6250e2cb6145c4ca5cdbdbcad9202aa5d606741161f235fc6c20244
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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 / p4rust-0.1.18-cp39-abi3-win_arm64.whl

Download URL p4rust-0.1.18-cp39-abi3-win_arm64.whl
Size 3.1 MB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
5ccf42f1da1b48622ad42a73a9b84abc1cf432b6d76e98866ba22db868eba8f7
BLAKE2b-256 checksum
How to use checksums
d7f48030f97a1d46b06e83954434438f21f7a4eca56c18dc2e21946e93c20709
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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 / p4rust-0.1.18-cp39-abi3-win_amd64.whl

Download URL p4rust-0.1.18-cp39-abi3-win_amd64.whl
Size 3.5 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
8e6997cd6649f8a0ede463616ccc11439deb59dff170a54553ebb7e8036c73fb
BLAKE2b-256 checksum
How to use checksums
efd2acb81b994629f38ee8efdead74ac1d08f42a676bf744743736126230c455
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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 / p4rust-0.1.18-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL p4rust-0.1.18-cp39-abi3-manylinux_2_28_x86_64.whl
Size 4.1 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
f1969c10d012f171545a01c37480c5ee58e908a9e719e676ad3d1a337b04a79a
BLAKE2b-256 checksum
How to use checksums
f965c800512ca1d8ed208e7033fa739de4811237deed5ed50b6c873142565f0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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 / p4rust-0.1.18-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL p4rust-0.1.18-cp39-abi3-manylinux_2_28_aarch64.whl
Size 4.3 MB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
4cf01aa160ba2c14e0512f24fd1a2b336c2542dee7afaaeda60ce87d0ba01a3f
BLAKE2b-256 checksum
How to use checksums
dd76ae87af1b9a8df23518d82419b0a9e943df15616c0be2d5c855e1725d12fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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 / p4rust-0.1.18-cp39-abi3-macosx_12_0_x86_64.whl

Download URL p4rust-0.1.18-cp39-abi3-macosx_12_0_x86_64.whl
Size 3.3 MB
Tags CPython 3.9 abi3 macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
0308f4ebca81b3967b7cfe9604aa687d95ec2bc2b4788e094a4367581f9bf2ea
BLAKE2b-256 checksum
How to use checksums
bcb3cb6b0f875a152b6d9e2d92072aa7c30b489868ef9884d7dfe5b418c36959
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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 / p4rust-0.1.18-cp39-abi3-macosx_12_0_arm64.whl

Download URL p4rust-0.1.18-cp39-abi3-macosx_12_0_arm64.whl
Size 3.6 MB
Tags CPython 3.9 abi3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
47a7aca09db4d2e672e7199819fb203fc934393db06d0cca423fa12d59be8b3f
BLAKE2b-256 checksum
How to use checksums
97a6aaccb68d640f75d1d8990a56cd804f895ce8aeb38cac7fdc7b718cfed188
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.24 {"installer":{"name":"uv","version":"0.12.24","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}

Security for p4rust 0.1.18

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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