Debian Codegraph @

cachestorage/types.go

raw
1 package cachestorage
2
3 // Code generated by cdproto-gen. DO NOT EDIT.
4
5 import (
6 "fmt"
7 "strings"
8
9 "github.com/chromedp/cdproto/storage"
10 )
11
12 // CacheID unique identifier of the Cache object.
13 //
14 // See: https://chromedevtools.github.io/devtools-protocol/tot/CacheStorage#type-CacheId
15 type CacheID string
16
17 // String returns the CacheID as string value.
18 func (t CacheID) String() string {
19 return string(t)
20 }
21
22 // CachedResponseType type of HTTP response cached.
23 //
24 // See: https://chromedevtools.github.io/devtools-protocol/tot/CacheStorage#type-CachedResponseType
25 type CachedResponseType string
26
27 // String returns the CachedResponseType as string value.
28 func (t CachedResponseType) String() string {
29 return string(t)
30 }
31
32 // CachedResponseType values.
33 const (
34 CachedResponseTypeBasic CachedResponseType = "basic"
35 CachedResponseTypeCors CachedResponseType = "cors"
36 CachedResponseTypeDefault CachedResponseType = "default"
37 CachedResponseTypeError CachedResponseType = "error"
38 CachedResponseTypeOpaqueResponse CachedResponseType = "opaqueResponse"
39 CachedResponseTypeOpaqueRedirect CachedResponseType = "opaqueRedirect"
40 )
41
42 // UnmarshalJSON satisfies [json.Unmarshaler].
43 func (t *CachedResponseType) UnmarshalJSON(buf []byte) error {
44 s := string(buf)
45 s = strings.TrimSuffix(strings.TrimPrefix(s, `"`), `"`)
46
47 switch CachedResponseType(s) {
48 case CachedResponseTypeBasic:
49 *t = CachedResponseTypeBasic
50 case CachedResponseTypeCors:
51 *t = CachedResponseTypeCors
52 case CachedResponseTypeDefault:
53 *t = CachedResponseTypeDefault
54 case CachedResponseTypeError:
55 *t = CachedResponseTypeError
56 case CachedResponseTypeOpaqueResponse:
57 *t = CachedResponseTypeOpaqueResponse
58 case CachedResponseTypeOpaqueRedirect:
59 *t = CachedResponseTypeOpaqueRedirect
60 default:
61 return fmt.Errorf("unknown CachedResponseType value: %v", s)
62 }
63 return nil
64 }
65
66 // DataEntry data entry.
67 //
68 // See: https://chromedevtools.github.io/devtools-protocol/tot/CacheStorage#type-DataEntry
69 type DataEntry struct {
70 RequestURL string `json:"requestURL"` // Request URL.
71 RequestMethod string `json:"requestMethod"` // Request method.
72 RequestHeaders []*Header `json:"requestHeaders"` // Request headers
73 ResponseTime float64 `json:"responseTime"` // Number of seconds since epoch.
74 ResponseStatus int64 `json:"responseStatus"` // HTTP response status code.
75 ResponseStatusText string `json:"responseStatusText"` // HTTP response status text.
76 ResponseType CachedResponseType `json:"responseType"` // HTTP response type
77 ResponseHeaders []*Header `json:"responseHeaders"` // Response headers
78 }
79
80 // Cache cache identifier.
81 //
82 // See: https://chromedevtools.github.io/devtools-protocol/tot/CacheStorage#type-Cache
83 type Cache struct {
84 CacheID CacheID `json:"cacheId"` // An opaque unique id of the cache.
85 SecurityOrigin string `json:"securityOrigin"` // Security origin of the cache.
86 StorageKey string `json:"storageKey"` // Storage key of the cache.
87 StorageBucket *storage.Bucket `json:"storageBucket,omitempty,omitzero"` // Storage bucket of the cache.
88 CacheName string `json:"cacheName"` // The name of the cache.
89 }
90
91 // Header [no description].
92 //
93 // See: https://chromedevtools.github.io/devtools-protocol/tot/CacheStorage#type-Header
94 type Header struct {
95 Name string `json:"name"`
96 Value string `json:"value"`
97 }
98
99 // CachedResponse cached response.
100 //
101 // See: https://chromedevtools.github.io/devtools-protocol/tot/CacheStorage#type-CachedResponse
102 type CachedResponse struct {
103 Body string `json:"body"` // Entry content, base64-encoded.
104 }