mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-25 18:49:36 -06:00
This makes the new typed serialization the default (the old serialization is not used but the code has not been cleaned up yet). Some things are no working in the new world: Chunking - The compound list is not working correctly any more. The Chunks method is having issues because it assumed things based on the old implicit chunking. Commit - uses a `Set(Commit)` which means that the parent commit is embedded. We need to change that to be `Set(Ref(Commit))` so that the parent commit is referenced instead.
50 lines
758 B
Go
50 lines
758 B
Go
package types
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/attic-labs/noms/ref"
|
|
)
|
|
|
|
type String struct {
|
|
s string
|
|
ref *ref.Ref
|
|
}
|
|
|
|
func NewString(s string) String {
|
|
return String{s, &ref.Ref{}}
|
|
}
|
|
|
|
func (fs String) Blob() (Blob, error) {
|
|
return NewBlob(bytes.NewBufferString(fs.s))
|
|
}
|
|
|
|
func (fs String) String() string {
|
|
return fs.s
|
|
}
|
|
|
|
func (fs String) Ref() ref.Ref {
|
|
return EnsureRef(fs.ref, fs)
|
|
}
|
|
|
|
func (s String) Equals(other Value) bool {
|
|
if other, ok := other.(String); ok {
|
|
return s.Ref() == other.Ref()
|
|
}
|
|
return false
|
|
}
|
|
|
|
func (fs String) Chunks() []Future {
|
|
return nil
|
|
}
|
|
|
|
var typeRefForString = MakePrimitiveTypeRef(StringKind)
|
|
|
|
func (fs String) TypeRef() TypeRef {
|
|
return typeRefForString
|
|
}
|
|
|
|
func StringFromVal(v Value) String {
|
|
return v.(String)
|
|
}
|