func (b *TupleBuilder) PutInt32(field string, value int32) (wrote uint64, err error) {

	// field type should be
	if err = b.typeCheck(field, Int32Field); err != nil {
		return 0, err
	}

	unsigned := uint32(value)
	if unsigned < math.MaxUint8 {

		// minimum bytes is 2 (type code + value)
		if b.available() < 2 {
			return 0, xbinary.ErrOutOfRange
		}

		// write type code
		b.buffer[b.pos] = byte(Int8Code.OpCode)

		// write value
		b.buffer[b.pos+1] = byte(value)

		// set field offset
		b.offsets[field] = b.pos

		// incr pos
		b.pos += 2

		return 2, nil
	} else if unsigned < math.MaxUint16 {

		// write value
		// length check performed by xbinary
		wrote, err = xbinary.LittleEndian.PutInt16(b.buffer, b.pos+1, int16(value))
		if err != nil {
			return 0, err
		}

		// write type code
		b.buffer[b.pos] = byte(Int16Code.OpCode)

		// set field offset
		b.offsets[field] = b.pos

		// incr pos
		b.pos += 3

		// wrote 3 bytes
		return 3, nil
	}

	// write value
	// length check performed by xbinary
	wrote, err = xbinary.LittleEndian.PutInt32(b.buffer, b.pos+1, value)
	if err != nil {
		return 0, err
	}

	// write type code
	b.buffer[b.pos] = byte(Int32Code.OpCode)

	// set field offset
	b.offsets[field] = b.pos

	// incr pos
	b.pos += 5

	// wrote 5 bytes
	return 5, nil
}
func (b *TupleBuilder) PutInt32(field string, value int32) (wrote uint64, err error) {

	// field type should be
	if err = b.typeCheck(field, Int32Field); err != nil {
		return 0, err
	}

	unsigned := uint32(value)
	if unsigned < math.MaxUint8 {

		// minimum bytes is 2 (type code + value)
		if b.available() < 2 {
			return 0, xbinary.ErrOutOfRange
		}

		// write type code
		b.buffer[b.pos] = byte(Int8Code.OpCode)

		// write value
		b.buffer[b.pos+1] = byte(value)

		// set field offset
		b.offsets[field] = b.pos

		// incr pos
		b.pos += 2

		return 2, nil
	} else if unsigned < math.MaxUint16 {

		// write value
		// length check performed by xbinary
		wrote, err = xbinary.LittleEndian.PutInt16(b.buffer, b.pos+1, int16(value))
		if err != nil {
			return 0, err
		}

		// write type code
		b.buffer[b.pos] = byte(Int16Code.OpCode)

		// set field offset
		b.offsets[field] = b.pos

		// incr pos
		b.pos += 3

		// wrote 3 bytes
		return 3, nil
	}

	// write value
	// length check performed by xbinary
	wrote, err = xbinary.LittleEndian.PutInt32(b.buffer, b.pos+1, value)
	if err != nil {
		return 0, err
	}

	// write type code
	b.buffer[b.pos] = byte(Int32Code.OpCode)

	// set field offset
	b.offsets[field] = b.pos

	// incr pos
	b.pos += 5

	// wrote 5 bytes
	return 5, nil
}
// PutInt32 sets a 32-bit signed value for the given field name. The field name must be a Int32Field. Otherwise, an error will be returned. If the type buffer no longer has enough space to write the value, an `xbinary.ErrOutOfRange` error will be returned. Upon success, the number of bytes written as well as a nil error will be returned. The type code will be written first. If the absolute value is `< math.MaxUint8`, only 1 byte will be written. If the absolute value is `< math.MaxUint16`, only 2 bytes will be written. Otherwise, the entire 32-bit value will be written.