-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhsds_entity_type.go
39 lines (31 loc) · 1.03 KB
/
hsds_entity_type.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
// Copyright 2022 UL Method Park GmbH. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "fmt"
// hsdsEntityType is a representation of HSDS object types.
type hsdsEntityType byte
const (
entityTypeGroup hsdsEntityType = 'g'
entityTypeDataset hsdsEntityType = 'd'
entityTypeCommittedType hsdsEntityType = 't'
)
// Valid returns, whether t is a valid entity type.
func (t hsdsEntityType) Valid() bool {
return (t == entityTypeGroup || t == entityTypeDataset || t == entityTypeCommittedType)
}
// unknownEntityTypeError is an error indicating that the an unknown entity type
// has been encountered.
type unknownEntityTypeError struct {
Type hsdsEntityType
}
func (err *unknownEntityTypeError) Error() string {
return fmt.Sprintf("hsds: unknown HDF5 type '%c'", err.Type)
}
func (err *unknownEntityTypeError) Is(other error) bool {
x, ok := other.(*unknownEntityTypeError)
if !ok {
return false
}
return x.Type == err.Type
}