o
    ҷh                     @  s|   d dl mZ ddlmZmZ d dlmZ d dlZd dlZddl	m
Z
 G dd deZdddZ		ddddZdddZdS )    )annotations   )event_classT_JSON_DICT)	dataclassN)runtimec                      s8   e Zd ZdZdddZedddZ fd	d
Z  ZS )StreamHandlez
    This is either obtained from another method or specified as ``blob:<uuid>`` where
    ``<uuid>`` is an UUID of a Blob.
    returnstrc                 C  s   | S N selfr   r   ]/var/www/html/venv/lib/python3.10/site-packages/selenium/webdriver/common/devtools/v119/io.pyto_json   s   zStreamHandle.to_jsonjsonc                 C  s   | |S r   r   )clsr   r   r   r   	from_json   s   zStreamHandle.from_jsonc                   s   d t  S )NzStreamHandle({}))formatsuper__repr__r   	__class__r   r   r      s   zStreamHandle.__repr__)r	   r
   )r   r
   r	   r   )	__name__
__module____qualname____doc__r   classmethodr   r   __classcell__r   r   r   r   r      s    
r   handler	   0typing.Generator[T_JSON_DICT, T_JSON_DICT, None]c                 c  s(    t  }|  |d< d|d}|V }dS )zu
    Close the stream, discard any temporary backing storage.

    :param handle: Handle of the stream to close.
    r   zIO.closemethodparamsN)dictr   )r   r#   cmd_dictr   r   r   r   close   s   
r&   offsettyping.Optional[int]sizeZtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.Tuple[typing.Optional[bool], str, bool]]c                 c  sr    t  }|  |d< |dur||d< |dur||d< d|d}|V }d|v r,t|d ndt|d t|d	 fS )
a  
    Read a chunk of the stream

    :param handle: Handle of the stream to read.
    :param offset: *(Optional)* Seek to the specified offset before reading (if not specificed, proceed with offset following the last read). Some types of streams may only support sequential reads.
    :param size: *(Optional)* Maximum number of bytes to read (left upon the agent discretion if not specified).
    :returns: A tuple with the following items:

        0. **base64Encoded** - *(Optional)* Set if the data is base64-encoded
        1. **data** - Data that were read.
        2. **eof** - Set if the end-of-file condition occurred while reading.
    r   Nr'   r)   zIO.readr!   base64Encodeddataeof)r$   r   boolr
   )r   r'   r)   r#   r%   r   r   r   r   read0   s   

r/   	object_idruntime.RemoteObjectId/typing.Generator[T_JSON_DICT, T_JSON_DICT, str]c                 c  s0    t  }|  |d< d|d}|V }t|d S )z
    Return UUID of Blob object specified by a remote object id.

    :param object_id: Object id of a Blob object wrapper.
    :returns: UUID of the specified Blob.
    objectIdzIO.resolveBlobr!   uuid)r$   r   r
   )r0   r#   r%   r   r   r   r   resolve_blobS   s   	r5   )r   r   r	   r    )NN)r   r   r'   r(   r)   r(   r	   r*   )r0   r1   r	   r2   )
__future__r   utilr   r   dataclassesr   enumtyping r   r
   r   r&   r/   r5   r   r   r   r   <module>   s   
#