コード例 #1
0
ファイル: rpc.go プロジェクト: startupit69/go-capnproto2
func transformToPromisedAnswer(s *capnp.Segment, answer rpccapnp.PromisedAnswer, transform []capnp.PipelineOp) error {
	opList, err := rpccapnp.NewPromisedAnswer_Op_List(s, int32(len(transform)))
	if err != nil {
		return err
	}
	for i, op := range transform {
		opList.At(i).SetGetPointerField(uint16(op.Field))
	}
	err = answer.SetTransform(opList)
	return err
}
コード例 #2
0
func formatPromisedAnswer(w io.Writer, a rpccapnp.PromisedAnswer) {
	fmt.Fprintf(w, "(question %d)", a.QuestionId())
	trans, _ := a.Transform()
	for i := 0; i < trans.Len(); i++ {
		t := trans.At(i)
		switch t.Which() {
		case rpccapnp.PromisedAnswer_Op_Which_noop:
		case rpccapnp.PromisedAnswer_Op_Which_getPointerField:
			fmt.Fprintf(w, ".getPointerField(%d)", t.GetPointerField())
		default:
			fmt.Fprintf(w, ".UNKNOWN(%v)", t.Which())
		}
	}
}