o
    ҷhY                     @  s   d dl mZ d dlZd dlmZ d dlmZmZmZ d dl	Z	d dl
mZmZ er.d dlmZ G dd deZed	ed
Zz
d dl
mZ dZW n eyQ   dZY nw edddZdddZdS )    )annotationsN)contextmanager)TYPE_CHECKINGProtocolTypeVar)SOCK_STREAMsocket)	Generatorc                   @  s   e Zd ZdddZdS )ClosablereturnNonec                 C  s   d S N )selfr   r   S/var/www/html/venv/lib/python3.10/site-packages/trio/_highlevel_open_unix_stream.pyclose   s    zClosable.closeN)r   r   )__name__
__module____qualname__r   r   r   r   r   r
      s    r
   CloseT)bound)AF_UNIXTFobjr   Generator[CloseT, None, None]c                 c  s     z| V  W d S    |     r   )r   )r   r   r   r   close_on_error   s   r   filename3str | bytes | os.PathLike[str] | os.PathLike[bytes]trio.SocketStreamc                   s`   t stdttt}t| |t| I dH  W d   n1 s&w   Y  t	
|S )a  Opens a connection to the specified
    `Unix domain socket <https://en.wikipedia.org/wiki/Unix_domain_socket>`__.

    You must have read/write permission on the specified file to connect.

    Args:
      filename (str or bytes): The filename to open the connection to.

    Returns:
      SocketStream: a :class:`~trio.abc.Stream` connected to the given file.

    Raises:
      OSError: If the socket file could not be connected to.
      RuntimeError: If AF_UNIX sockets are not supported.
    z/Unix sockets are not supported on this platformN)has_unixRuntimeErrorr   r   r   r   connectosfspathtrioSocketStream)r   sockr   r   r   open_unix_socket&   s   


r&   )r   r   r   r   )r   r   r   r   )
__future__r   r!   
contextlibr   typingr   r   r   r#   trio.socketr   r   collections.abcr	   r
   r   r   r   ImportErrorr   r&   r   r   r   r   <module>   s&    