type.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. package thrift
  20. // Type constants in the Thrift protocol
  21. type TType byte
  22. const (
  23. STOP = 0
  24. VOID = 1
  25. BOOL = 2
  26. BYTE = 3
  27. I08 = 3
  28. DOUBLE = 4
  29. I16 = 6
  30. I32 = 8
  31. I64 = 10
  32. STRING = 11
  33. UTF7 = 11
  34. STRUCT = 12
  35. MAP = 13
  36. SET = 14
  37. LIST = 15
  38. UTF8 = 16
  39. UTF16 = 17
  40. BINARY = 18
  41. )
  42. var typeNames = map[int]string{
  43. STOP: "STOP",
  44. VOID: "VOID",
  45. BOOL: "BOOL",
  46. BYTE: "BYTE",
  47. I16: "I16",
  48. I32: "I32",
  49. I64: "I64",
  50. STRING: "STRING",
  51. STRUCT: "STRUCT",
  52. MAP: "MAP",
  53. SET: "SET",
  54. LIST: "LIST",
  55. UTF8: "UTF8",
  56. UTF16: "UTF16",
  57. }
  58. func (p TType) String() string {
  59. if s, ok := typeNames[int(p)]; ok {
  60. return s
  61. }
  62. return "Unknown"
  63. }