o
    Ð­jW  ã                   @  sj   d dl mZ d dlmZ ddlmZ ddlmZmZ g d¢Z	G dd„ dƒZ
G d	d
„ d
ƒZG dd„ dƒZdS )é    )Úannotations)ÚSequenceé   )ÚFrame)ÚExtensionNameÚExtensionParameter)Ú	ExtensionÚClientExtensionFactoryÚServerExtensionFactoryc                   @  s6   e Zd ZU dZded< 	 ddœddd„Zddd„ZdS )r   z%
    Base class for extensions.

    r   ÚnameN)Úmax_sizeÚframer   r   ú
int | NoneÚreturnc                C  ó   t ‚)a  
        Decode an incoming frame.

        Args:
            frame: Incoming frame.
            max_size: Maximum payload size in bytes.

        Returns:
            Decoded frame.

        Raises:
            PayloadTooBig: If decoding the payload exceeds ``max_size``.

        ©ÚNotImplementedError)Úselfr   r   © r   úW/var/www/html/CropPilot/venv/lib/python3.10/site-packages/websockets/extensions/base.pyÚdecode   s   zExtension.decodec                 C  r   )z‹
        Encode an outgoing frame.

        Args:
            frame: Outgoing frame.

        Returns:
            Encoded frame.

        r   )r   r   r   r   r   Úencode&   s   zExtension.encode)r   r   r   r   r   r   )r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   r   r   r   r   r      s   
 r   c                   @  s0   e Zd ZU dZded< 	 ddd„Zddd„ZdS )r	   z:
    Base class for client-side extension factories.

    r   r   r   úSequence[ExtensionParameter]c                 C  r   )z�
        Build parameters to send to the server for this extension.

        Returns:
            Parameters to send to the server.

        r   )r   r   r   r   Úget_request_params=   s   z)ClientExtensionFactory.get_request_paramsÚparamsÚaccepted_extensionsúSequence[Extension]r   c                 C  r   )ah  
        Process parameters received from the server.

        Args:
            params: Parameters received from the server for this extension.
            accepted_extensions: List of previously accepted extensions.

        Returns:
            An extension instance.

        Raises:
            NegotiationError: If parameters aren't acceptable.

        r   ©r   r   r    r   r   r   Úprocess_response_paramsG   s   z.ClientExtensionFactory.process_response_paramsN)r   r   )r   r   r    r!   r   r   )r   r   r   r   r   r   r#   r   r   r   r   r	   4   s   
 

r	   c                   @  s&   e Zd ZU dZded< 	 dd
d„ZdS )r
   z:
    Base class for server-side extension factories.

    r   r   r   r   r    r!   r   ú*tuple[list[ExtensionParameter], Extension]c                 C  r   )aÿ  
        Process parameters received from the client.

        Args:
            params: Parameters received from the client for this extension.
            accepted_extensions: List of previously accepted extensions.

        Returns:
            To accept the offer, parameters to send to the client for this
            extension and an extension instance.

        Raises:
            NegotiationError: To reject the offer, if parameters received from
                the client aren't acceptable.

        r   r"   r   r   r   Úprocess_request_paramsf   s   z-ServerExtensionFactory.process_request_paramsN)r   r   r    r!   r   r$   )r   r   r   r   r   r%   r   r   r   r   r
   ]   s
   
 r
   N)Ú
__future__r   Úcollections.abcr   Úframesr   Útypingr   r   Ú__all__r   r	   r
   r   r   r   r   Ú<module>   s    ()