/
registry.go
52 lines (46 loc) · 1.26 KB
/
registry.go
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
package asset
import (
"fmt"
"image"
"io"
)
// ErrNotFound indicates that the specified content is not available.
var ErrNotFound = fmt.Errorf("not found")
// Encodable represents an asset that can be serialized.
type Encodable interface {
EncodeTo(out io.Writer) error
}
// Decodable represents an asset that can be deserialized.
type Decodable interface {
DecodeFrom(in io.Reader) error
}
// Registry represents a managment interface for assets.
type Registry interface {
Resources() []Resource
ResourceByID(id string) Resource
ResourceByName(name string) Resource
ResourcesByName(name string) []Resource
CreateResource(kind, name string) Resource
// CreateIDResource is deprecated and available only due to the old
// pack mechanism.
CreateIDResource(id, kind, name string) Resource
Save() error
}
// Resource represents the generic aspects of an asset.
type Resource interface {
ID() string
Kind() string
Name() string
SetName(name string)
Dependants() []Resource
Dependencies() []Resource
AddDependency(resource Resource)
RemoveDependency(resource Resource)
ReadPreview() (image.Image, error)
WritePreview(image.Image) error
DeletePreview() error
ReadContent(target Decodable) error
WriteContent(source Encodable) error
DeleteContent() error
Delete()
}