Metadata-Version: 2.4
Name: transports
Version: 0.4.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 as incremental patches.

Define a model once as a [pydantic](https://docs.pydantic.dev) model, stdlib `dataclass`, or
[msgspec](https://jcristharif.com/msgspec/) struct. Host it in Python, mutate it normally, and send
only the patch needed to update a remote mirror. The same Rust core drives Python (PyO3) and
JavaScript (wasm), so both sides use the same `Value`, diff, patch, and codec machinery.

[![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")
model_id = session.host(lamp)

lamp.on = True
print(session.drain())
# [(1, {'rev': 1, 'ops': [{'Set': {'path': [{'Key': 'on'}], 'value': {'Bool': True}}}]})]
```

## Install

```bash
pip install transports
pip install "transports[connections]"   # WebSocket server/client adapters
pip install "transports[sse]"           # Server-Sent Events adapter
pip install "transports[jupyter]"       # Jupyter comm adapter
```

## Documentation

### Tutorial

[Quickstart](docs/src/quickstart.md) builds one hosted model and mirrors it with the in-process
server/client protocol.

### How-to guides

[Model bridges](docs/src/bridges.md) covers pydantic, dataclasses, msgspec, schemas, and plain
JavaScript objects. [Connections](docs/src/connections.md) covers WebSocket, SSE, Jupyter comm, and
anywidget adapters. [Codecs](docs/src/codecs.md) covers JSON, MessagePack, and custom codecs.
[Multi-tenancy and sharing](docs/src/multitenancy.md) covers tenant isolation, shared models, and
merge strategies.

### Reference

[API reference](docs/src/api.md) lists the Python API. [Wire protocol reference](docs/src/protocol-reference.md)
describes `Value`, patch operations, protocol messages, codecs, and model ids.

### Explanation

[Concepts](docs/src/concepts.md) explains why transports uses incremental patches, server-owned
revisions, a shared Rust core, and transport-agnostic adapters.
