U
    g                     @  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
ddZddddddddZdddddZdS )    )annotations   )event_classT_JSON_DICT)	dataclassN)runtimec                      sB   e Zd ZdZddddZedd 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.
    str)returnc                 C  s   | S N selfr   r   N/tmp/pip-unpacked-wheel-3ysq0mf8/selenium/webdriver/common/devtools/v129/io.pyto_json   s    zStreamHandle.to_json)jsonr
   c                 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__)	__name__
__module____qualname____doc__r   classmethodr   r   __classcell__r   r   r   r   r      s
   r   z0typing.Generator[T_JSON_DICT, T_JSON_DICT, None])handler
   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%   ztyping.Optional[int]zZtyping.Generator[T_JSON_DICT, T_JSON_DICT, typing.Tuple[typing.Optional[bool], str, bool]])r   offsetsizer
   c                 c  sp   t  }|  |d< |dk	r"||d< |dk	r2||d< d|d}|V }d|krVt|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 specified, 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    Zbase64Encodeddataeof)r#   r   boolr	   )r   r&   r'   r"   r$   r   r   r   r   read0   s    

r+   zruntime.RemoteObjectIdz/typing.Generator[T_JSON_DICT, T_JSON_DICT, str])	object_idr
   c                 c  s.   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.
    ZobjectIdzIO.resolveBlobr    uuid)r#   r   r	   )r,   r"   r$   r   r   r   r   resolve_blobS   s    	r.   )NN)
__future__r   utilr   r   Zdataclassesr   enumtyping r   r	   r   r%   r+   r.   r   r   r   r   <module>   s     #