"""
This file is generated by generator/run.py based on the Chrome DevTools Protocol.

Input/Output operations for streams produced by DevTools.
https://chromedevtools.github.io/devtools-protocol/tot/IO/

***************************************************
                    Methods
***************************************************
"""
from __future__ import annotations

from cdpkit.protocol._types import (
    IO,
    Runtime,
)
from cdpkit.protocol.base import CDPMethod, InputModel, OutputModel


class CloseInput(InputModel):

    handle: IO.StreamHandle


class Close(CDPMethod[None]):
    """ Close the stream, discard any temporary backing storage. """

    INPUT_VALIDATOR = CloseInput
    OUTPUT_VALIDATOR = None

    def __init__(
        self,
        *,
        handle: IO.StreamHandle
    ):
        super().__init__(
            handle=handle
        )


class ReadInput(InputModel):

    handle: IO.StreamHandle
    offset: int | None = None
    size: int | None = None


class ReadOutput(OutputModel):

    base64Encoded: bool | None = None
    data: str
    eof: bool


class Read(CDPMethod[ReadOutput]):
    """ Read a chunk of the stream """

    INPUT_VALIDATOR = ReadInput
    OUTPUT_VALIDATOR = ReadOutput

    def __init__(
        self,
        *,
        handle: IO.StreamHandle,
        offset: int | None = None,
        size: int | None = None
    ):
        super().__init__(
            handle=handle,
            offset=offset,
            size=size
        )


class ResolveBlobInput(InputModel):

    objectId: Runtime.RemoteObjectId


class ResolveBlobOutput(OutputModel):

    uuid: str


class ResolveBlob(CDPMethod[ResolveBlobOutput]):
    """ Return UUID of Blob object specified by a remote object id. """

    INPUT_VALIDATOR = ResolveBlobInput
    OUTPUT_VALIDATOR = ResolveBlobOutput

    def __init__(
        self,
        *,
        object_id: Runtime.RemoteObjectId
    ):
        super().__init__(
            objectId=object_id
        )
