transports¶
Move typed models across any wire as incremental patches.
Define a model once as a pydantic model, stdlib dataclass, or
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.
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¶
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 builds one hosted model and mirrors it with the in-process server/client protocol.
How-to guides¶
Model bridges covers pydantic, dataclasses, msgspec, schemas, and plain JavaScript objects. Connections covers WebSocket, SSE, Jupyter comm, and anywidget adapters. Codecs covers JSON, MessagePack, and custom codecs. Multi-tenancy and sharing covers tenant isolation, shared models, and merge strategies.
Reference¶
API reference lists the Python API. Wire protocol reference
describes Value, patch operations, protocol messages, codecs, and model ids.
Explanation¶
Concepts explains why transports uses incremental patches, server-owned revisions, a shared Rust core, and transport-agnostic adapters.