Portal LogoPortal Docs

pxp Library Overview

Introduction to pxp, the consumer-agnostic Rust implementation of the Portal Transfer Protocol.

pxp Library

The pxp library is a headless, consumer-agnostic Rust implementation of the Portal Transfer Protocol (PXP). It is decoupled from any specific user interface, making it suitable for command-line tools, desktop applications (such as Tauri or Electron wrappers), mobile applications, and background daemons.


Key Design Principles

  1. No Side Effects The library never writes to stdout/stderr or reads from stdin. All logger outputs use the standard tracing facade.
  2. Standard Traits for UI Decoupling All user-facing behaviors — such as displaying progress bars, printing transfer status messages, and resolving filename conflicts — are abstracted into traits that the caller implements.
  3. Pure Async/Await Built on top of tokio for non-blocking network I/O, UDP broadcasting, and filesystem streaming.
  4. Strongly-Typed Errors Contains a comprehensive, typed error taxonomy (PxpError) built using thiserror (no anyhow dependencies).

Crate Structure

The crate is organized into several modules representing protocol stages:

  • discovery — Broadcasts and listens for UDP beacons.
  • sender — Discovers receivers, establishes TCP handshakes, creates metadata manifests, and streams TAR archives.
  • receiver — Binds listeners, receives handshake proofs, decodes manifests, stages streams to disk, and reconciles conflicts into the target directory.
  • metadata — Shared models representing files, directories, manifests, and transfer items.
  • error — Crate-wide error enum (PxpError) and Result type alias.

On this page