
    h                        S SK Jr  S SKJrJr  S SKJrJr  S SKJ	r	  SSK
JrJrJrJr  SSKJrJr  \" SS	9 " S
 S\5      5       rg)    )annotations)CallableMapping)	dataclassfield)Any   )ClosedResourceErrorDelimiterNotFoundEndOfStreamIncompleteRead)AnyByteReceiveStreamByteReceiveStreamF)eqc                      \ rS rSr% SrS\S'   \" S\S9rS\S'   \" SSS	9r	S
\S'   SS jr
\SS j5       r\SS j5       rSSS jjrSS jrSS jrSrg)BufferedByteReceiveStream   z
Wraps any bytes-based receive stream and uses a buffer to provide sophisticated
receiving capabilities in the form of a byte stream.
r   receive_streamF)initdefault_factory	bytearray_buffer)r   defaultbool_closedc                b   #    U R                   R                  5       I S h  vN   SU l        g  N7f)NT)r   acloser   selfs    H/var/www/html/env/lib/python3.13/site-packages/anyio/streams/buffered.pyr    BufferedByteReceiveStream.aclose   s)     !!((*** 	+s   /-/c                ,    [        U R                  5      $ )z"The bytes currently in the buffer.)bytesr   r   s    r    buffer BufferedByteReceiveStream.buffer   s     T\\""    c                .    U R                   R                  $ N)r   extra_attributesr   s    r    r)   *BufferedByteReceiveStream.extra_attributes   s    ""333r&   c                  #    U R                   (       a  [        eU R                  (       a)  [        U R                  S U 5      nU R                  S U2	 U$ [	        U R
                  [        5      (       a#  U R
                  R                  U5      I S h  vN $ U R
                  R                  5       I S h  vN n[        U5      U:  a"  U R                  R                  X!S  5        US U $ U$  NY N97fr(   )
r   r
   r   r#   
isinstancer   r   receivelenextend)r   	max_byteschunks      r    r-   !BufferedByteReceiveStream.receive#   s     <<%%<<$,,z	23EZiZ(L++->??,,44Y??? --5577E5zI%##E*$56Zi(( @ 8s$   BC/C+!C/3C-48C/-C/c                  #     U[        U R                  5      -
  nUS::  a)  U R                  SU nU R                  SU2	 [        U5      $  [        U R                  [
        5      (       a$  U R                  R                  U5      I Sh  vN nO#U R                  R                  5       I Sh  vN n U R                  R                  U5        M   NE N$! [         a  n[        UeSnAff = f7f)z
Read exactly the given amount of bytes from the stream.

:param nbytes: the number of bytes to read
:return: the bytes read
:raises ~anyio.IncompleteRead: if the stream was closed before the requested
    amount of bytes could be read from the stream

r   N)
r.   r   r#   r,   r   r   r-   r   r   r/   )r   nbytes	remainingretvalr1   excs         r    receive_exactly)BufferedByteReceiveStream.receive_exactly8   s      T\\!22IA~gv.LL&)V}$.d113DEE"&"5"5"="=i"HHE"&"5"5"="="??E LL&  I? .$#-.sZ   A	C,=C 	C
C C,C ,C-C 1C,C C 
C)C$$C))C,c                  #    [        U5      nSn U R                  R                  X5      nUS:  a5  U R                  SU nU R                  SU[        U5      -   2	 [        U5      $ [        U R                  5      U:  a  [	        U5      e U R
                  R                  5       I Sh  vN n[        [        U R                  5      U-
  S-   S5      nU R                  R                  U5        M   NF! [         a  n[        UeSnAff = f7f)a  
Read from the stream until the delimiter is found or max_bytes have been read.

:param delimiter: the marker to look for in the stream
:param max_bytes: maximum number of bytes that will be read before raising
    :exc:`~anyio.DelimiterNotFound`
:return: the bytes read (not including the delimiter)
:raises ~anyio.IncompleteRead: if the stream was closed before the delimiter
    was found
:raises ~anyio.DelimiterNotFound: if the delimiter is not found within the
    bytes read up to the maximum allowed

r   N   )r.   r   findr#   r   r   r-   r   r   maxr/   )	r   	delimiterr0   delimiter_sizeoffsetindexfounddatar7   s	            r    receive_until'BufferedByteReceiveStream.receive_untilS   s      YLL%%i8EzVe,LL!;53y>#9!;<U|# 4<< I-'	22.!0088::
 T\\*^;a?CFLL%)  ; .$#-.s=   B	DC2 )C0*C2 .AD0C2 2
D<DDD)r   N)returnNone)rF   r#   )rF   zMapping[Any, Callable[[], Any]])i   )r0   intrF   r#   )r4   rH   rF   r#   )r>   r#   r0   rH   rF   r#   )__name__
__module____qualname____firstlineno____doc____annotations__r   r   r   r   r   propertyr$   r)   r-   r8   rD   __static_attributes__ r&   r    r   r      sm    
 )(E9EGYEue4GT4 # # 4 4*'6$&r&   r   N)
__future__r   collections.abcr   r   dataclassesr   r   typingr    r
   r   r   r   abcr   r   r   rQ   r&   r    <module>rX      s>    " - (  R R 9 ek& 1 k& k&r&   