Exemple #1
0
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
}
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())
		}
	}
}