File: types.go

package info (click to toggle)
golang-github-chromedp-cdproto 0.0~git20230109.6b041c6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,584 kB
  • sloc: makefile: 2
file content (68 lines) | stat: -rw-r--r-- 2,289 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package headlessexperimental

// Code generated by cdproto-gen. DO NOT EDIT.

import (
	"fmt"

	"github.com/mailru/easyjson"
	"github.com/mailru/easyjson/jlexer"
	"github.com/mailru/easyjson/jwriter"
)

// ScreenshotParams encoding options for a screenshot.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/HeadlessExperimental#type-ScreenshotParams
type ScreenshotParams struct {
	Format           ScreenshotParamsFormat `json:"format,omitempty"`           // Image compression format (defaults to png).
	Quality          int64                  `json:"quality,omitempty"`          // Compression quality from range [0..100] (jpeg only).
	OptimizeForSpeed bool                   `json:"optimizeForSpeed,omitempty"` // Optimize image encoding for speed, not for resulting size (defaults to false)
}

// ScreenshotParamsFormat image compression format (defaults to png).
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/HeadlessExperimental#type-ScreenshotParams
type ScreenshotParamsFormat string

// String returns the ScreenshotParamsFormat as string value.
func (t ScreenshotParamsFormat) String() string {
	return string(t)
}

// ScreenshotParamsFormat values.
const (
	ScreenshotParamsFormatJpeg ScreenshotParamsFormat = "jpeg"
	ScreenshotParamsFormatPng  ScreenshotParamsFormat = "png"
	ScreenshotParamsFormatWebp ScreenshotParamsFormat = "webp"
)

// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ScreenshotParamsFormat) MarshalEasyJSON(out *jwriter.Writer) {
	out.String(string(t))
}

// MarshalJSON satisfies json.Marshaler.
func (t ScreenshotParamsFormat) MarshalJSON() ([]byte, error) {
	return easyjson.Marshal(t)
}

// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ScreenshotParamsFormat) UnmarshalEasyJSON(in *jlexer.Lexer) {
	v := in.String()
	switch ScreenshotParamsFormat(v) {
	case ScreenshotParamsFormatJpeg:
		*t = ScreenshotParamsFormatJpeg
	case ScreenshotParamsFormatPng:
		*t = ScreenshotParamsFormatPng
	case ScreenshotParamsFormatWebp:
		*t = ScreenshotParamsFormatWebp

	default:
		in.AddError(fmt.Errorf("unknown ScreenshotParamsFormat value: %v", v))
	}
}

// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ScreenshotParamsFormat) UnmarshalJSON(buf []byte) error {
	return easyjson.Unmarshal(buf, t)
}