package extensions

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

import (
	"fmt"

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

// StorageArea storage areas.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Extensions#type-StorageArea
type StorageArea string

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

// StorageArea values.
const (
	StorageAreaSession StorageArea = "session"
	StorageAreaLocal   StorageArea = "local"
	StorageAreaSync    StorageArea = "sync"
	StorageAreaManaged StorageArea = "managed"
)

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

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

// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *StorageArea) UnmarshalEasyJSON(in *jlexer.Lexer) {
	v := in.String()
	switch StorageArea(v) {
	case StorageAreaSession:
		*t = StorageAreaSession
	case StorageAreaLocal:
		*t = StorageAreaLocal
	case StorageAreaSync:
		*t = StorageAreaSync
	case StorageAreaManaged:
		*t = StorageAreaManaged

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

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