typeMethods.go 1.1 KB
Newer Older
1
package typesystem
2

3 4 5 6 7 8
import (
	"github.com/ipld/go-ipld-prime"
)

func (TypeBool) ReprKind() ipld.ReprKind {
	return ipld.ReprKind_Bool
9
}
10 11
func (TypeString) ReprKind() ipld.ReprKind {
	return ipld.ReprKind_String
12
}
13 14
func (TypeBytes) ReprKind() ipld.ReprKind {
	return ipld.ReprKind_Bytes
15
}
16 17
func (TypeInt) ReprKind() ipld.ReprKind {
	return ipld.ReprKind_Int
18
}
19 20
func (TypeFloat) ReprKind() ipld.ReprKind {
	return ipld.ReprKind_Float
21
}
22 23
func (TypeMap) ReprKind() ipld.ReprKind {
	return ipld.ReprKind_Map
24
}
25 26
func (TypeList) ReprKind() ipld.ReprKind {
	return ipld.ReprKind_List
27
}
28 29
func (TypeLink) ReprKind() ipld.ReprKind {
	return ipld.ReprKind_Link
30
}
31
func (tv TypeUnion) ReprKind() ipld.ReprKind {
32 33
	// REVIEW: this may fib; has the bizarre property of being dependent on the *concrete value* for kinded unions!
	if tv.Style == UnionStyle_Kinded {
34
		return ipld.ReprKind_Invalid
35
	} else {
36
		return ipld.ReprKind_Map
37 38
	}
}
39
func (tv TypeObject) ReprKind() ipld.ReprKind {
40
	if tv.TupleStyle {
41
		return ipld.ReprKind_List
42
	} else {
43
		return ipld.ReprKind_Map
44 45
	}
}
46 47
func (TypeEnum) ReprKind() ipld.ReprKind {
	return ipld.ReprKind_String
48
}