o
    iU	                     @   sP   d Z ddlmZmZ ddlmZmZ eG dd deZeG dd deZdS )	uJ  Interface definitions for custom WebSocket transports.

Implement one of these protocols to provide a custom transport to the
Deepgram SDK via the ``transport_factory`` parameter::

    from deepgram import DeepgramClient
    from deepgram.transport_interface import SyncTransport

    class MyTransport:
        """Custom transport — must satisfy SyncTransport."""

        def __init__(self, url: str, headers: dict):
            ...  # establish your connection here

        def send(self, data):
            ...  # send text (str) or binary (bytes) data

        def recv(self):
            ...  # return the next message (str or bytes)

        def __iter__(self):
            ...  # yield messages until the connection closes

        def close(self):
            ...  # tear down the connection

    client = DeepgramClient(api_key="...", transport_factory=MyTransport)

The transport factory is the **class itself** (or any callable). The SDK
calls ``factory(url, headers)`` and gets back a transport object. The SDK
handles context-manager wrapping and calls ``close()`` automatically.
    )AnyIterator)Protocolruntime_checkablec                   @   sH   e Zd ZdZdeddfddZdefddZdefd	d
ZdddZ	dS )SyncTransportay  Protocol that sync transport objects must satisfy.

    Methods
    -------
    send(data)
        Send text (``str``) or binary (``bytes``) data over the connection.
    recv()
        Block until the next message arrives and return it.
    __iter__()
        Yield messages until the connection closes.
    close()
        Tear down the connection and release resources.
    datareturnNc                 C      d S N selfr   r   r   P/home/ubuntu/.local/lib/python3.10/site-packages/deepgram/transport_interface.pysend7       zSyncTransport.sendc                 C   r	   r
   r   r   r   r   r   recv8   r   zSyncTransport.recvc                 C   r	   r
   r   r   r   r   r   __iter__9   r   zSyncTransport.__iter__c                 C   r	   r
   r   r   r   r   r   close:   r   zSyncTransport.closer   N)
__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r   r   '       r   c                   @   sH   e Zd ZdZdeddfddZdefddZdefd	d
ZdddZdS )AsyncTransportas  Protocol that async transport objects must satisfy.

    Methods
    -------
    send(data)
        Send text (``str``) or binary (``bytes``) data over the connection.
    recv()
        Await the next message and return it.
    __aiter__()
        Async-yield messages until the connection closes.
    close()
        Tear down the connection and release resources.
    r   r   Nc                       d S r
   r   r   r   r   r   r   M       zAsyncTransport.sendc                    r   r
   r   r   r   r   r   r   N   r   zAsyncTransport.recvc                 C   r	   r
   r   r   r   r   r   	__aiter__O   r   zAsyncTransport.__aiter__c                    r   r
   r   r   r   r   r   r   P   r   zAsyncTransport.closer   )	r   r   r   r   r   r   r   r   r   r   r   r   r   r   =   r   r   N)	r   typingr   r   typing_extensionsr   r   r   r   r   r   r   r   <module>   s    !