Returns nil byte on error
(v types.Val, typ types.TypeID)
| 185 | |
| 186 | // Returns nil byte on error |
| 187 | func convertToType(v types.Val, typ types.TypeID) (*pb.TaskValue, error) { |
| 188 | result := &pb.TaskValue{ValType: typ.Enum(), Val: x.Nilbyte} |
| 189 | if v.Tid == typ { |
| 190 | result.Val = v.Value.([]byte) |
| 191 | return result, nil |
| 192 | } |
| 193 | |
| 194 | // convert data from binary to appropriate format |
| 195 | val, err := types.Convert(v, typ) |
| 196 | if err != nil { |
| 197 | return result, err |
| 198 | } |
| 199 | // Marshal |
| 200 | data := types.ValueForType(types.BinaryID) |
| 201 | err = types.Marshal(val, &data) |
| 202 | if err != nil { |
| 203 | return result, errors.Errorf("Failed convertToType during Marshal") |
| 204 | } |
| 205 | result.Val = data.Value.([]byte) |
| 206 | return result, nil |
| 207 | } |
| 208 | |
| 209 | // FuncType represents the type of a query function (aggregation, has, etc). |
| 210 | type FuncType int |
no test coverage detected