Skip to content

Transport

Base classes

Name Children Inherits
Protocol
typing
Base class for protocol classes.

⋔ Inheritance diagram

graph TD
  2107932809["transport.Transport"]
  1073422405["typing.Protocol"]
  3481597255["typing.Generic"]
  2751680898["builtins.object"]
  1073422405 --> 2107932809
  3481597255 --> 1073422405
  2751680898 --> 3481597255

🛈 DocStrings

Bases: Protocol

Abstract transport for bidirectional JSON message exchange.

Source code in src/codexed/transport.py
@runtime_checkable
class Transport(Protocol):
    """Abstract transport for bidirectional JSON message exchange."""

    async def start(self) -> None:
        """Open the transport connection."""
        ...

    async def stop(self) -> None:
        """Close the transport connection and release resources."""
        ...

    async def send(self, message: dict[str, Any]) -> None:
        """Send a JSON message over the transport."""
        ...

    async def receive(self) -> dict[str, Any] | None:
        """Receive the next JSON message, or None if the transport is closed."""
        ...

    @property
    def is_connected(self) -> bool:
        """Whether the transport is currently connected."""
        ...

is_connected property

is_connected: bool

Whether the transport is currently connected.

receive async

receive() -> dict[str, Any] | None

Receive the next JSON message, or None if the transport is closed.

Source code in src/codexed/transport.py
async def receive(self) -> dict[str, Any] | None:
    """Receive the next JSON message, or None if the transport is closed."""
    ...

send async

send(message: dict[str, Any]) -> None

Send a JSON message over the transport.

Source code in src/codexed/transport.py
async def send(self, message: dict[str, Any]) -> None:
    """Send a JSON message over the transport."""
    ...

start async

start() -> None

Open the transport connection.

Source code in src/codexed/transport.py
async def start(self) -> None:
    """Open the transport connection."""
    ...

stop async

stop() -> None

Close the transport connection and release resources.

Source code in src/codexed/transport.py
async def stop(self) -> None:
    """Close the transport connection and release resources."""
    ...

:fa-brands-github: Show source on GitHub