2017-01-24 15:09:23 +00:00
|
|
|
// Package io provides the Chrome Debugging Protocol
|
2017-02-12 04:59:33 +00:00
|
|
|
// commands, types, and events for the IO domain.
|
2017-01-24 15:09:23 +00:00
|
|
|
//
|
|
|
|
// Input/Output operations for streams produced by DevTools.
|
|
|
|
//
|
|
|
|
// Generated by the chromedp-gen command.
|
|
|
|
package io
|
|
|
|
|
2017-07-09 02:05:19 +00:00
|
|
|
// Code generated by chromedp-gen. DO NOT EDIT.
|
2017-01-24 15:09:23 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
cdp "github.com/knq/chromedp/cdp"
|
2017-01-24 15:09:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ReadParams read a chunk of the stream.
|
|
|
|
type ReadParams struct {
|
|
|
|
Handle StreamHandle `json:"handle"` // Handle of the stream to read.
|
|
|
|
Offset int64 `json:"offset,omitempty"` // Seek to the specified offset before reading (if not specificed, proceed with offset following the last read).
|
|
|
|
Size int64 `json:"size,omitempty"` // Maximum number of bytes to read (left upon the agent discretion if not specified).
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read read a chunk of the stream.
|
|
|
|
//
|
|
|
|
// parameters:
|
|
|
|
// handle - Handle of the stream to read.
|
|
|
|
func Read(handle StreamHandle) *ReadParams {
|
|
|
|
return &ReadParams{
|
|
|
|
Handle: handle,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithOffset seek to the specified offset before reading (if not specificed,
|
|
|
|
// proceed with offset following the last read).
|
|
|
|
func (p ReadParams) WithOffset(offset int64) *ReadParams {
|
|
|
|
p.Offset = offset
|
|
|
|
return &p
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithSize maximum number of bytes to read (left upon the agent discretion
|
|
|
|
// if not specified).
|
|
|
|
func (p ReadParams) WithSize(size int64) *ReadParams {
|
|
|
|
p.Size = size
|
|
|
|
return &p
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReadReturns return values.
|
|
|
|
type ReadReturns struct {
|
|
|
|
Data string `json:"data,omitempty"` // Data that were read.
|
2017-03-02 03:24:35 +00:00
|
|
|
EOF bool `json:"eof,omitempty"` // Set if the end-of-file condition occurred while reading.
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-02-12 04:59:33 +00:00
|
|
|
// Do executes IO.read against the provided context and
|
|
|
|
// target handler.
|
2017-01-24 15:09:23 +00:00
|
|
|
//
|
|
|
|
// returns:
|
|
|
|
// data - Data that were read.
|
2017-03-02 03:24:35 +00:00
|
|
|
// eof - Set if the end-of-file condition occurred while reading.
|
2017-02-12 04:59:33 +00:00
|
|
|
func (p *ReadParams) Do(ctxt context.Context, h cdp.Handler) (data string, eof bool, err error) {
|
2017-02-14 08:41:23 +00:00
|
|
|
// execute
|
|
|
|
var res ReadReturns
|
|
|
|
err = h.Execute(ctxt, cdp.CommandIORead, p, &res)
|
2017-01-24 15:09:23 +00:00
|
|
|
if err != nil {
|
|
|
|
return "", false, err
|
|
|
|
}
|
|
|
|
|
2017-02-14 08:41:23 +00:00
|
|
|
return res.Data, res.EOF, nil
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CloseParams close the stream, discard any temporary backing storage.
|
|
|
|
type CloseParams struct {
|
|
|
|
Handle StreamHandle `json:"handle"` // Handle of the stream to close.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close close the stream, discard any temporary backing storage.
|
|
|
|
//
|
|
|
|
// parameters:
|
|
|
|
// handle - Handle of the stream to close.
|
|
|
|
func Close(handle StreamHandle) *CloseParams {
|
|
|
|
return &CloseParams{
|
|
|
|
Handle: handle,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-12 04:59:33 +00:00
|
|
|
// Do executes IO.close against the provided context and
|
|
|
|
// target handler.
|
|
|
|
func (p *CloseParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
|
2017-02-14 08:41:23 +00:00
|
|
|
return h.Execute(ctxt, cdp.CommandIOClose, p, nil)
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|