mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-31 03:18:43 -06:00
This is needed to be able to round trip enums. If there is no codegen for an enum that is read from the datastore we now return a types.Enum which can be serialized back to the same sequence.
30 lines
472 B
Go
30 lines
472 B
Go
package types
|
|
|
|
import "github.com/attic-labs/noms/ref"
|
|
|
|
type Enum struct {
|
|
v uint32
|
|
t TypeRef
|
|
}
|
|
|
|
func newEnum(v uint32, t TypeRef) Enum {
|
|
return Enum{v, t}
|
|
}
|
|
|
|
func (e Enum) Equals(other Value) bool {
|
|
return other != nil && e.t.Equals(other.TypeRef()) && e.Ref() == other.Ref()
|
|
}
|
|
|
|
func (e Enum) Ref() ref.Ref {
|
|
throwaway := ref.Ref{}
|
|
return EnsureRef(&throwaway, e)
|
|
}
|
|
|
|
func (e Enum) Chunks() []ref.Ref {
|
|
return nil
|
|
}
|
|
|
|
func (e Enum) TypeRef() TypeRef {
|
|
return e.t
|
|
}
|