summaryrefslogtreecommitdiff
path: root/lib/go/thrift/compact_protocol.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/go/thrift/compact_protocol.go')
-rw-r--r--lib/go/thrift/compact_protocol.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/go/thrift/compact_protocol.go b/lib/go/thrift/compact_protocol.go
index dc86fe605..18915fee8 100644
--- a/lib/go/thrift/compact_protocol.go
+++ b/lib/go/thrift/compact_protocol.go
@@ -52,6 +52,7 @@ const (
COMPACT_SET = 0x0A
COMPACT_MAP = 0x0B
COMPACT_STRUCT = 0x0C
+ COMPACT_UUID = 0x0D
)
var (
@@ -72,6 +73,7 @@ func init() {
SET: COMPACT_SET,
MAP: COMPACT_MAP,
STRUCT: COMPACT_STRUCT,
+ UUID: COMPACT_UUID,
}
}
@@ -354,6 +356,12 @@ func (p *TCompactProtocol) WriteBinary(ctx context.Context, bin []byte) error {
return nil
}
+// Write a Tuuid to the wire as 16 bytes.
+func (p *TCompactProtocol) WriteUUID(ctx context.Context, value Tuuid) error {
+ _, err := p.trans.Write(value[:])
+ return NewTProtocolException(err)
+}
+
//
// Reading methods.
//
@@ -639,6 +647,16 @@ func (p *TCompactProtocol) ReadBinary(ctx context.Context) (value []byte, err er
return buf, NewTProtocolException(e)
}
+// Read fixed 16 bytes as UUID.
+func (p *TCompactProtocol) ReadUUID(ctx context.Context) (value Tuuid, err error) {
+ buf := p.buffer[0:16]
+ _, e := io.ReadFull(p.trans, buf)
+ if e == nil {
+ copy(value[:], buf)
+ }
+ return value, NewTProtocolException(e)
+}
+
func (p *TCompactProtocol) Flush(ctx context.Context) (err error) {
return NewTProtocolException(p.trans.Flush(ctx))
}
@@ -825,6 +843,8 @@ func (p *TCompactProtocol) getTType(t tCompactType) (TType, error) {
return MAP, nil
case COMPACT_STRUCT:
return STRUCT, nil
+ case COMPACT_UUID:
+ return UUID, nil
}
return STOP, NewTProtocolException(fmt.Errorf("don't know what type: %v", t&0x0f))
}