Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

SLIM Python Bindings (UniFFI)

Python bindings for SLIM (Secure Low-Latency Interactive Messaging) using UniFFI.

This provides a Python interface to the SLIM data plane, enabling secure, low-latency messaging with support for point-to-point and group (multicast) communication patterns.

Overview

These Python bindings are generated from the agntcy-slim-bindings-ffi crate using UniFFI, providing a native Python interface that wraps the high-performance Rust implementation.

Key Features

  • Point-to-Point Messaging: Direct communication between two endpoints
  • Group Messaging: Multicast communication with multiple participants
  • Secure by Default: Support for TLS, mTLS, and various authentication methods
  • MLS Encryption: End-to-end encryption for sessions
  • Delivery Confirmation: Optional completion handles for reliable messaging
  • Flexible Authentication: Shared secrets, JWT, SPIRE integration
  • slimrpc Support: Protocol Buffers RPC over SLIM - see SLIMRPC.md for details

Architecture

The Python bindings are built using Maturin, which automatically generates Python bindings from the Rust UniFFI adapter:

slim-bindings/
├── rust/          # Rust UniFFI bindings (shared by Go, Python, etc.)
│   ├── src/
│   │   ├── app.rs
│   │   ├── build_info.rs
│   │   ├── client_config.rs
│   │   ├── common_config.rs
│   │   ├── completion_handle.rs
│   │   ├── config.rs
│   │   ├── errors.rs
│   │   ├── identity.rs
│   │   ├── identity_config.rs
│   │   ├── init_config.rs
│   │   ├── lib.rs
│   │   ├── message_context.rs
│   │   ├── name.rs
│   │   ├── server_config.rs
│   │   ├── service.rs
│   │   └── session.rs
│   └── Cargo.toml
├── go/               # Go-specific bindings and examples
└── python/           # Python-specific bindings and examples (this directory)
    ├── examples/              # Example applications
    ├── tests/                 # Unit and integration tests
    └── Taskfile.yaml          # Build and development tasks

Prerequisites

  • Rust toolchain (1.70+)
  • Python (3.10+)
  • uv (Python package manager): https://docs.astral.sh/uv/
  • Task (optional, for convenient build commands)

Installation

Development Build

cd python
task python:bindings:build

This will:

  1. Install all dependencies
  2. Compile the Rust UniFFI adapter
  3. Generate Python bindings using Maturin
  4. Install the package in development mode

Creating Distribution Packages

Build Wheels for Multiple Python Versions

To create distributable wheel packages for Python 3.10, 3.11, 3.12, 3.13 and 3.14:

task python:bindings:packaging

Or directly with Maturin:

uv run maturin build --release -i 3.10 3.11 3.12 3.13

Maturin automatically:

  1. Compiles the Rust UniFFI adapter library
  2. Generates Python bindings from UniFFI scaffolding
  3. Bundles the native library into platform-specific wheels
  4. Creates wheels for each specified Python version

The resulting wheels are self-contained and ready for distribution.

Custom Build Options

You can customize the build with the following variables:

# Build for a specific target architecture
task python:bindings:packaging TARGET=aarch64-apple-darwin

# Build in debug mode (default is release)
task python:bindings:packaging PROFILE=debug

# Cross-compile for Linux on macOS
task python:bindings:packaging TARGET=x86_64-unknown-linux-gnu

Output Structure

After running the packaging task, you'll find:

dist/
├── slim_uniffi_bindings-0.7.0-cp310-*.whl  # Python 3.10 wheel
├── slim_uniffi_bindings-0.7.0-cp311-*.whl  # Python 3.11 wheel
├── slim_uniffi_bindings-0.7.0-cp312-*.whl  # Python 3.12 wheel
└── slim_uniffi_bindings-0.7.0-cp313-*.whl  # Python 3.13 wheel

Note: The native library is automatically bundled inside each wheel.

Installing from Wheel

Users can install the wheel package directly:

pip install slim_uniffi_bindings-0.7.0-cp310-*.whl

The native library is automatically included in the wheel and will be loaded at runtime.

Examples

Examples are a separate project in the examples/ directory.

See examples/README.md for detailed instructions.

Quick Start with Examples

cd examples

# View available examples
task

# Run simple example
task simple

# Run point-to-point examples
task p2p:alice    # Terminal 1
task p2p:bob      # Terminal 2

Quick Start

Simple Example

import slim_uniffi_bindings as slim

# Initialize crypto provider
slim.initialize_crypto_provider()

# Get version
print(f"SLIM Version: {slim.get_version()}")

# Create an app with shared secret authentication
app_name = {
    'components': ['org', 'example', 'app'],
    'id': None
}
app = slim.create_app_with_secret(app_name, "my-secret")

print(f"App ID: {app.id()}")
print(f"App Name: {'/'.join(app.name().components)}")

Run the simple example:

cd examples
task simple

Point-to-Point Communication

Terminal 1 - Receiver (Alice):

cd examples
task p2p:alice

Terminal 2 - Sender (Bob):

cd examples
task p2p:bob

Group Communication

Terminal 1 - Participant (Alice):

cd examples
task group:participant:alice

Terminal 2 - Participant (Bob):

cd examples
task group:participant:bob

Terminal 3 - Moderator:

cd examples
task group:moderator

For more details, see examples/README.md.

API Overview

Application Creation

# Create app with shared secret
app = slim.create_app_with_secret(app_name, shared_secret)

# Get app information
app_id = app.id()
app_name = app.name()

Server Operations

# Connect to server
client_config = {
    'endpoint': 'http://localhost:46357',
    'tls': {'insecure': True, ...}
}
conn_id = app.connect(client_config)

# Run server
server_config = {
    'endpoint': '127.0.0.1:46357',
    'tls': {'insecure': True, ...}
}
app.run_server(server_config)

# Disconnect
app.disconnect(conn_id)

Session Management

# Create session
session_config = {
    'session_type': 'PointToPoint',  # or 'Group'
    'enable_mls': False,
    'max_retries': 3,
    'interval_ms': 100,
    'initiator': True,
    'metadata': {}
}
session = app.create_session(session_config, destination_name)

# Listen for incoming session
session = app.listen_for_session(timeout_ms=30000)

# Delete session
app.delete_session(session)

Messaging

# Send message (fire-and-forget)
session.publish(data, "text/plain", metadata)

# Send with delivery confirmation
completion = session.publish_with_completion(data, "text/plain", metadata)
completion.wait()  # Block until delivered

# Receive message
msg = session.get_message(timeout_ms=5000)
print(f"Payload: {msg.payload}")
print(f"From: {msg.context.source_name}")
print(f"Type: {msg.context.payload_type}")

# Reply to message
session.publish_to(msg.context, reply_data, "text/plain", None)

Group Operations

# Invite participant to group
session.invite(participant_name)

# Remove participant
session.remove(participant_name)

Examples

Examples Directory Structure

examples/
├── common/
│   └── common.py          # Shared utilities
├── simple/
│   └── main.py            # Basic functionality demo
├── point_to_point/
│   └── main.py            # P2P messaging
└── group/
    └── main.py            # Group/multicast messaging

Running Examples

All examples require a running SLIM server. Start the Go server:

cd go
task example:server

Then run Python examples:

# Simple example
task example

# Point-to-point
task example:p2p:alice      # Terminal 1
task example:p2p:bob        # Terminal 2

# Group messaging
task example:group:participant:alice    # Terminal 1
task example:group:participant:bob      # Terminal 2
task example:group:moderator            # Terminal 3

Testing

Unit Tests

task test
# or
python -m pytest tests/unit_test.py -v

Integration Tests

Integration tests require a running SLIM server:

# Terminal 1: Start server
cd ../go && task example:server

# Terminal 2: Run integration tests
SLIM_INTEGRATION_TEST=1 python -m pytest tests/integration_test.py -v -s

Development

Available Tasks

task                           # Show help
task build                     # Build package with Maturin
task test                      # Run tests
task python:bindings:packaging # Build wheels for multiple Python versions
task clean                     # Clean build artifacts

Project Structure

  • slim_uniffi_bindings/ - Python package (bindings generated by Maturin)
  • examples/ - Example applications
  • tests/ - Unit and integration tests
  • Taskfile.yaml - Build automation
  • pyproject.toml - Package configuration (Maturin build system)

Comparison with Go Bindings

Both Python and Go bindings use the same UniFFI adapter, ensuring API consistency:

Feature Python Go
Binding Generation uniffi-bindgen uniffi-bindgen-go
API Style Pythonic (snake_case) Idiomatic Go (PascalCase)
Error Handling Exceptions Error returns
Async Support Sync wrapper over async Rust Sync wrapper over async Rust
Examples
Tests

API Reference

Core Types

  • Name: Application/service identifier with components and optional ID
  • SessionConfig: Configuration for creating sessions
  • TlsConfig: TLS settings for secure connections
  • ServerConfig: Server endpoint and TLS configuration
  • ClientConfig: Client endpoint and TLS configuration
  • MessageContext: Message metadata (source, destination, type, metadata)
  • ReceivedMessage: Received message with context and payload

Main Classes

  • BindingsAdapter: Main app interface for session management
  • BindingsSessionContext: Session interface for messaging
  • FfiCompletionHandle: Completion handle for delivery confirmation

Session Types

  • PointToPoint: Direct one-to-one communication
  • Group: One-to-many multicast communication

Troubleshooting

ImportError: Cannot find slim_uniffi_bindings

Make sure you've built the package:

task build
# or
uv run maturin develop

Connection Refused

Ensure the SLIM server is running:

cd ../go && task example:server

Build Errors

If you encounter build errors, try cleaning and rebuilding:

task clean
uv run maturin develop

Contributing

When contributing to the Python bindings:

  1. Maintain API consistency with Go bindings
  2. Follow Python naming conventions (snake_case)
  3. Add tests for new functionality
  4. Update examples if adding features
  5. Keep documentation up to date

License

Apache-2.0 - See LICENSE.md for details

See Also

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

slim_bindings-2.0.0a7-py3-none-win_arm64.whl (16.2 MB view details)

Uploaded Python 3Windows ARM64

slim_bindings-2.0.0a7-py3-none-win_amd64.whl (17.3 MB view details)

Uploaded Python 3Windows x86-64

slim_bindings-2.0.0a7-py3-none-musllinux_1_2_x86_64.whl (19.7 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

slim_bindings-2.0.0a7-py3-none-musllinux_1_2_aarch64.whl (19.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

slim_bindings-2.0.0a7-py3-none-manylinux_2_28_x86_64.whl (19.7 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

slim_bindings-2.0.0a7-py3-none-manylinux_2_28_aarch64.whl (19.1 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

slim_bindings-2.0.0a7-py3-none-macosx_11_0_arm64.whl (18.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

slim_bindings-2.0.0a7-py3-none-macosx_10_12_x86_64.whl (19.0 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file slim_bindings-2.0.0a7-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for slim_bindings-2.0.0a7-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 683472ff28ce4c7f87c699ee64b4a60ae9caabbb0ddfaf92d332f48a6cb059aa
MD5 7166bd82570815b764c92821be21e697
BLAKE2b-256 0752c1588d29247823cff8cc272790bb56c04692577b9fb9330c37593dedd27f

See more details on using hashes here.

Provenance

The following attestation bundles were made for slim_bindings-2.0.0a7-py3-none-win_arm64.whl:

Publisher: release-bindings.yaml on agntcy/slim-bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slim_bindings-2.0.0a7-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for slim_bindings-2.0.0a7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 95e949d8c22df78e1aa8b16e5599e9c402977642df919f227b7e2de4b616bb02
MD5 9fab99b54a625e97b8898463a2225970
BLAKE2b-256 f74aeef3cf96f69acccaa800747746b4c4b2e87561900c53fdf57dbaaf612705

See more details on using hashes here.

Provenance

The following attestation bundles were made for slim_bindings-2.0.0a7-py3-none-win_amd64.whl:

Publisher: release-bindings.yaml on agntcy/slim-bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slim_bindings-2.0.0a7-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for slim_bindings-2.0.0a7-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ecfc4a89dd6aa2c5cf356718db3fe01b2c1ed471c5b54402477880986f78fc9f
MD5 0a2f3e2ed8ef6969f37fd4c0cad6bcec
BLAKE2b-256 4168a606f58c6bb7fbc065ad2877cca43adbb41797acd52724f8257b34293120

See more details on using hashes here.

Provenance

The following attestation bundles were made for slim_bindings-2.0.0a7-py3-none-musllinux_1_2_x86_64.whl:

Publisher: release-bindings.yaml on agntcy/slim-bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slim_bindings-2.0.0a7-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for slim_bindings-2.0.0a7-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 fadf0c8bb720eaa368fe7a5d9c212f1521639f4f2868260f1d2ac0913c9bf1cc
MD5 f5919a5ef8349cee0021116745563539
BLAKE2b-256 060dfd1fe867509db1d902b4612a35850107497afb1dedb9b3f79d91186b81a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for slim_bindings-2.0.0a7-py3-none-musllinux_1_2_aarch64.whl:

Publisher: release-bindings.yaml on agntcy/slim-bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slim_bindings-2.0.0a7-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for slim_bindings-2.0.0a7-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d059da0ec9dcd369e40523402b4643bb96af7142e2edd704fb13ee3f0ff01fe5
MD5 1c2d5c3246e11f92491182d7405c48fd
BLAKE2b-256 8dcd17e01090a3778904b427407ec1dd67685ae4c291b29e9c7a821b8cf78b03

See more details on using hashes here.

Provenance

The following attestation bundles were made for slim_bindings-2.0.0a7-py3-none-manylinux_2_28_x86_64.whl:

Publisher: release-bindings.yaml on agntcy/slim-bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slim_bindings-2.0.0a7-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for slim_bindings-2.0.0a7-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ca9b8e33c68751227b80b5f2388427022998c7c2cbe72d23400b1924292d0002
MD5 166a3bf9fa2a76a0835a1bb8806dcc82
BLAKE2b-256 a6b255548357b9f9eda8f7588c6d95bad112379e8fcb68a4d7dd2012939cd94c

See more details on using hashes here.

Provenance

The following attestation bundles were made for slim_bindings-2.0.0a7-py3-none-manylinux_2_28_aarch64.whl:

Publisher: release-bindings.yaml on agntcy/slim-bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slim_bindings-2.0.0a7-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for slim_bindings-2.0.0a7-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3f817dc3a44d12a82f8c27b57dfbd728ff84acf7b27bd286d05c347bb734a11f
MD5 4379e17e86f23431cd9b89e994c5f181
BLAKE2b-256 bc6baf2e34d58c91eff2b8bef8a92f2bccccd99961f23a9583193201168b79a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for slim_bindings-2.0.0a7-py3-none-macosx_11_0_arm64.whl:

Publisher: release-bindings.yaml on agntcy/slim-bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file slim_bindings-2.0.0a7-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for slim_bindings-2.0.0a7-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a0c2024d51677f3f16b1c668a30d4aa1f9b4cd3d60d1b67a0d654ca4563a1e38
MD5 5386eed988b4dc0c5245c0954f5f7887
BLAKE2b-256 ac1adf254e3c13db60211f895418d8686e32ec294f2be1d0560f8b8e385fdffb

See more details on using hashes here.

Provenance

The following attestation bundles were made for slim_bindings-2.0.0a7-py3-none-macosx_10_12_x86_64.whl:

Publisher: release-bindings.yaml on agntcy/slim-bindings

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

2.1.0

8 files

2.0.0

8 files

This release

2.0.0a7 This release

8 files

1.4.1

8 files

1.4.0

8 files

1.3.0

8 files

1.2.0

8 files

1.1.1

8 files

1.1.0

8 files

1.0.1

8 files

1.0.0

8 files

0.7.1

21 files

0.7.0

21 files

0.6.3

26 files

0.6.2

26 files

0.6.1

26 files

0.6.0

26 files

0.5.0

26 files

0.4.1

21 files

0.4.0

26 files

0.3.6

26 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page