TypeIDFor gives TypeID for facet.
(f *api.Facet)
| 157 | |
| 158 | // TypeIDFor gives TypeID for facet. |
| 159 | func TypeIDFor(f *api.Facet) (types.TypeID, error) { |
| 160 | switch f.ValType { |
| 161 | case api.Facet_INT: |
| 162 | return types.IntID, nil |
| 163 | case api.Facet_FLOAT: |
| 164 | return types.FloatID, nil |
| 165 | case api.Facet_BOOL: |
| 166 | return types.BoolID, nil |
| 167 | case api.Facet_DATETIME: |
| 168 | return types.DateTimeID, nil |
| 169 | case api.Facet_STRING: |
| 170 | return types.StringID, nil |
| 171 | default: |
| 172 | return types.DefaultID, errors.Errorf("Unrecognized facet type: %v", f.ValType) |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | // ValFor converts Facet into types.Val. |
| 177 | func ValFor(f *api.Facet) (types.Val, error) { |