code: func (p *ProcessingResult) WriteResult(r interface{}) error {
  	blob, err := json.Marshal(r)
  	switch {
  	case err != nil:
  		return errors.Annotate(err, "failed to serialize the result").Err()
  	case len(blob) == 0 || blob[0] != '{':
  		return errors.Reason("the result is not a JSON object").Err()
  	}
  	out := bytes.Buffer{}
  	z := zlib.NewWriter(&out)
  	if _, err := io.Copy(z, bytes.NewReader(blob)); err != nil {
  		z.Close()
  		return errors.Annotate(err, "failed to compress the result").Err()
  	}
  	if err := z.Close(); err != nil {
  		return errors.Annotate(err, "failed to close zlib writer").Err()
  	}
  	p.ResultRaw = out.Bytes()
  	return nil
  }
docs: // WriteResult overwrites ResultRaw field with compressed JSON-serialized 'r'.
  //
  // 'r' should serialize into a JSON object, e.g '{...}'.