mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-09 03:09:12 -06:00
The new serialization format use "t " as in typed. The rest of the message is a JSON array describing the typed data. The type is described by types.TypeRef Fixes #384 Issues #281, #304
37 lines
764 B
Cheetah
37 lines
764 B
Cheetah
// {{.Name}}
|
|
|
|
type {{.Name}} struct {
|
|
r ref.Ref
|
|
}
|
|
|
|
func New{{.Name}}(r ref.Ref) {{.Name}} {
|
|
return {{.Name}}{r}
|
|
}
|
|
|
|
func (r {{.Name}}) Ref() ref.Ref {
|
|
return r.r
|
|
}
|
|
|
|
func (r {{.Name}}) Equals(other {{.Name}}) bool {
|
|
return r.Ref() == other.Ref()
|
|
}
|
|
|
|
func (r {{.Name}}) NomsValue() types.Value {
|
|
return types.Ref{R: r.r}
|
|
}
|
|
|
|
func {{.Name}}FromVal(p types.Value) {{.Name}} {
|
|
return {{.Name}}{p.(types.Ref).Ref()}
|
|
}
|
|
|
|
{{template "type_ref.tmpl" .}}
|
|
|
|
func (r {{.Name}}) GetValue(cs chunks.ChunkSource) {{userType .ElemType}} {
|
|
return {{valueToUser "types.ReadValue(r.r, cs)" .ElemType}}
|
|
}
|
|
|
|
func (r {{.Name}}) SetValue(val {{userType .ElemType}}, cs chunks.ChunkSink) {{.Name}} {
|
|
ref := types.WriteValue({{userToValue "val" .ElemType}}, cs)
|
|
return {{.Name}}{ref}
|
|
}
|