Metadata-Version: 2.4
Name: transports
Version: 0.3.0
Summary: Generic communication library
Project-URL: Repository, https://github.com/1kbgz/transports
Project-URL: Homepage, https://github.com/1kbgz/transports
Author-email: 1kbgz <dev@1kbgz.com>
License: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Rust
Requires-Python: >=3.10
Requires-Dist: bigbrother>=0.1.4
Requires-Dist: msgspec
Requires-Dist: pydantic
Provides-Extra: connections
Requires-Dist: starlette; extra == 'connections'
Requires-Dist: websockets; extra == 'connections'
Provides-Extra: develop
Requires-Dist: build; extra == 'develop'
Requires-Dist: bump-my-version; extra == 'develop'
Requires-Dist: check-dist; extra == 'develop'
Requires-Dist: cibuildwheel; extra == 'develop'
Requires-Dist: codespell; extra == 'develop'
Requires-Dist: comm; extra == 'develop'
Requires-Dist: hatch-js; extra == 'develop'
Requires-Dist: hatch-rs; extra == 'develop'
Requires-Dist: hatchling; extra == 'develop'
Requires-Dist: httpx; extra == 'develop'
Requires-Dist: httpx-sse; extra == 'develop'
Requires-Dist: ipykernel; extra == 'develop'
Requires-Dist: mdformat; extra == 'develop'
Requires-Dist: mdformat-tables>=1; extra == 'develop'
Requires-Dist: pytest; extra == 'develop'
Requires-Dist: pytest-cov; extra == 'develop'
Requires-Dist: ruff; extra == 'develop'
Requires-Dist: sse-starlette; extra == 'develop'
Requires-Dist: starlette; extra == 'develop'
Requires-Dist: twine; extra == 'develop'
Requires-Dist: ty; extra == 'develop'
Requires-Dist: uv; extra == 'develop'
Requires-Dist: websockets; extra == 'develop'
Requires-Dist: wheel; extra == 'develop'
Provides-Extra: jupyter
Requires-Dist: comm; extra == 'jupyter'
Provides-Extra: sse
Requires-Dist: httpx; extra == 'sse'
Requires-Dist: httpx-sse; extra == 'sse'
Requires-Dist: sse-starlette; extra == 'sse'
Description-Content-Type: text/markdown

# transports

Move typed models across any wire.

Define a model once — as a [pydantic](https://docs.pydantic.dev) model, a stdlib `dataclass`, or a
[msgspec](https://jcristharif.com/msgspec/) struct — host it, and its mutations stream to peers as
**incremental patches** (not whole-model resends), over a WebSocket, in JSON or MessagePack. A Rust
core (model representation, diff/patch, codecs, framing) compiles to Python (PyO3) and JavaScript
(wasm), so both ends share one implementation.

[![License](https://img.shields.io/github/license/1kbgz/transports)](https://github.com/1kbgz/transports)
[![PyPI](https://img.shields.io/pypi/v/transports.svg)](https://pypi.python.org/pypi/transports)

```python
import transports
from pydantic import BaseModel

class Device(BaseModel):
    name: str
    on: bool = False

session = transports.Session()
lamp = Device(name="lamp")
session.host(lamp)

lamp.on = True                       # just mutate the model...
for model_id, patch in session.drain():
    print(patch)
    # {'rev': 1, 'ops': [{'Set': {'path': [{'Key': 'on'}], 'value': {'Bool': True}}}]}
```

## Install

```bash
pip install transports
pip install "transports[connections]"   # adds the WebSocket server/client adapters
```

## What you get

- **Reactive models** — mutate a field, get the minimal patch. No manual diffing or `send()`.
- **Three model kinds, one contract** — pydantic, dataclass, and msgspec all bridge to the same core.
- **One core, two languages** — Python and JavaScript share the Rust diff/patch and codecs, so a
  patch produced on one side applies on the other.
- **Live sync over WebSocket** — host a model on a server and mirror it in the browser; mutate it in
  Python and the page updates. See [Connections](docs/src/connections.md).
- **JSON or MessagePack** — swap the wire format without touching your models. See
  [Codecs](docs/src/codecs.md).

## Documentation

[Quickstart](docs/src/quickstart.md) · [Concepts](docs/src/concepts.md) ·
[Model bridges](docs/src/bridges.md) · [Connections](docs/src/connections.md) ·
[Codecs](docs/src/codecs.md) · [API reference](docs/src/api.md)
