Beispiel #1
0
// WriteValue writes the given Thrift value to the underlying stream using the
// Thrift Binary Protocol.
func (bw *Writer) WriteValue(v wire.Value) error {
	switch v.Type() {
	case wire.TBool:
		if v.GetBool() {
			return bw.writeByte(1)
		}
		return bw.writeByte(0)

	case wire.TI8:
		return bw.writeByte(byte(v.GetI8()))

	case wire.TDouble:
		value := math.Float64bits(v.GetDouble())
		return bw.writeInt64(int64(value))

	case wire.TI16:
		return bw.writeInt16(v.GetI16())

	case wire.TI32:
		return bw.writeInt32(v.GetI32())

	case wire.TI64:
		return bw.writeInt64(v.GetI64())

	case wire.TBinary:
		b := v.GetBinary()
		if err := bw.writeInt32(int32(len(b))); err != nil {
			return err
		}
		return bw.write(b)

	case wire.TStruct:
		return bw.writeStruct(v.GetStruct())

	case wire.TMap:
		return bw.writeMap(v.GetMap())

	case wire.TSet:
		return bw.writeSet(v.GetSet())

	case wire.TList:
		return bw.writeList(v.GetList())

	default:
		return fmt.Errorf("unknown ttype %v", v.Type())
	}
}
Beispiel #2
0
func (v *ExceptionType) FromWire(w wire.Value) error {
	*v = (ExceptionType)(w.GetI32())
	return nil
}
Beispiel #3
0
func (v *SimpleType) FromWire(w wire.Value) error {
	*v = (SimpleType)(w.GetI32())
	return nil
}
Beispiel #4
0
func (v *MyEnum2) FromWire(w wire.Value) error {
	*v = (MyEnum2)(w.GetI32())
	return nil
}
Beispiel #5
0
func (v *Feature) FromWire(w wire.Value) error {
	*v = (Feature)(w.GetI32())
	return nil
}
Beispiel #6
0
func (v *ServiceID) FromWire(w wire.Value) error {
	x, err := w.GetI32(), error(nil)
	*v = (ServiceID)(x)
	return err
}
Beispiel #7
0
func (v *EnumDefault) FromWire(w wire.Value) error {
	*v = (EnumDefault)(w.GetI32())
	return nil
}
Beispiel #8
0
func (v *ModuleID) FromWire(w wire.Value) error {
	x, err := w.GetI32(), error(nil)
	*v = (ModuleID)(x)
	return err
}
Beispiel #9
0
func (v *LowerCaseEnum) FromWire(w wire.Value) error {
	*v = (LowerCaseEnum)(w.GetI32())
	return nil
}
Beispiel #10
0
func (v *RecordType) FromWire(w wire.Value) error {
	*v = (RecordType)(w.GetI32())
	return nil
}
Beispiel #11
0
func (v *EnumWithValues) FromWire(w wire.Value) error {
	*v = (EnumWithValues)(w.GetI32())
	return nil
}
Beispiel #12
0
func (v *EmptyEnum) FromWire(w wire.Value) error {
	*v = (EmptyEnum)(w.GetI32())
	return nil
}
Beispiel #13
0
func (v *EnumWithDuplicateName) FromWire(w wire.Value) error {
	*v = (EnumWithDuplicateName)(w.GetI32())
	return nil
}