"""
This type stub file was generated by pyright.
"""

import abc
import ssl
from urllib.parse import ParseResult
from typing import List, Union

class Transport(abc.ABC):
    @abc.abstractmethod
    async def connect(self, uri: ParseResult, buffer_size: int, connect_timeout: int): # -> None:
        """
        Connects to a server using the implemented transport. The uri passed is of type ParseResult that can be
        obtained calling urllib.parse.urlparse.
        """
        ...
    
    @abc.abstractmethod
    async def connect_tls(self, uri: Union[str, ParseResult], ssl_context: ssl.SSLContext, buffer_size: int, connect_timeout: int): # -> None:
        """
        connect_tls is similar to connect except it tries to connect to a secure endpoint, using the provided ssl
        context. The uri can be provided as string in case the hostname differs from the uri hostname, in case it
        was provided as 'tls_hostname' on the options.
        """
        ...
    
    @abc.abstractmethod
    def write(self, payload: bytes): # -> None:
        """
        Write bytes to underlying transport. Needs a call to drain() to be successfully written.
        """
        ...
    
    @abc.abstractmethod
    def writelines(self, payload: List[bytes]): # -> None:
        """
        Writes a list of bytes, one by one, to the underlying transport. Needs a call to drain() to be successfully
        written.
        """
        ...
    
    @abc.abstractmethod
    async def read(self, buffer_size: int) -> bytes:
        """
        Reads a sequence of bytes from the underlying transport, up to buffer_size. The buffer_size is ignored in case
        the transport carries already frames entire messages (i.e. websocket).
        """
        ...
    
    @abc.abstractmethod
    async def readline(self) -> bytes:
        """
        Reads one whole frame of bytes (or message) from the underlying transport.
        """
        ...
    
    @abc.abstractmethod
    async def drain(self): # -> None:
        """
        Flushes the bytes queued for transmission when calling write() and writelines().
        """
        ...
    
    @abc.abstractmethod
    async def wait_closed(self): # -> None:
        """
        Waits until the connection is successfully closed.
        """
        ...
    
    @abc.abstractmethod
    def close(self): # -> None:
        """
        Closes the underlying transport.
        """
        ...
    
    @abc.abstractmethod
    def at_eof(self) -> bool:
        """
        Returns if underlying transport is at eof.
        """
        ...
    
    @abc.abstractmethod
    def __bool__(self): # -> None:
        """
        Returns if the transport was initialized, either by calling connect of connect_tls.
        """
        ...
    


class TcpTransport(Transport):
    def __init__(self) -> None:
        ...
    
    async def connect(self, uri: ParseResult, buffer_size: int, connect_timeout: int): # -> None:
        ...
    
    async def connect_tls(self, uri: Union[str, ParseResult], ssl_context: ssl.SSLContext, buffer_size: int, connect_timeout: int) -> None:
        ...
    
    def write(self, payload): # -> None:
        ...
    
    def writelines(self, payload): # -> None:
        ...
    
    async def read(self, buffer_size: int): # -> bytes:
        ...
    
    async def readline(self): # -> bytes:
        ...
    
    async def drain(self): # -> None:
        ...
    
    async def wait_closed(self): # -> None:
        ...
    
    def close(self): # -> None:
        ...
    
    def at_eof(self): # -> bool:
        ...
    
    def __bool__(self): # -> bool:
        ...
    


class WebSocketTransport(Transport):
    def __init__(self) -> None:
        ...
    
    async def connect(self, uri: ParseResult, buffer_size: int, connect_timeout: int): # -> None:
        ...
    
    async def connect_tls(self, uri: Union[str, ParseResult], ssl_context: ssl.SSLContext, buffer_size: int, connect_timeout: int): # -> None:
        ...
    
    def write(self, payload): # -> None:
        ...
    
    def writelines(self, payload): # -> None:
        ...
    
    async def read(self, buffer_size: int): # -> Literal[b""]:
        ...
    
    async def readline(self): # -> Literal[b""]:
        ...
    
    async def drain(self): # -> None:
        ...
    
    async def wait_closed(self): # -> None:
        ...
    
    def close(self): # -> None:
        ...
    
    def at_eof(self):
        ...
    
    def __bool__(self): # -> bool:
        ...
    


