Files
dolt/types/blob.go
T
2015-07-29 16:06:54 -07:00

49 lines
649 B
Go

package types
import (
"bytes"
"io"
"github.com/attic-labs/noms/ref"
)
type Blob struct {
data []byte
ref *ref.Ref
}
func (fb Blob) Reader() io.Reader {
return bytes.NewBuffer(fb.data)
}
func (fb Blob) Len() uint64 {
return uint64(len(fb.data))
}
func (fb Blob) Ref() ref.Ref {
return ensureRef(fb.ref, fb)
}
func (fb Blob) Equals(other Value) bool {
if other == nil {
return false
} else {
return fb.Ref() == other.Ref()
}
}
func (fb Blob) Chunks() []Future {
return nil
}
func (fb Blob) Release() {
}
func NewBlob(data []byte) Blob {
return Blob{data, &ref.Ref{}}
}
func BlobFromVal(v Value) Blob {
return v.(Blob)
}