structs_gen.go 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. package traffic
  2. // Code generated by go-bare/cmd/gen, DO NOT EDIT.
  3. import (
  4. "errors"
  5. "git.sr.ht/~sircmpwn/go-bare"
  6. )
  7. type Trip struct {
  8. Id string `bare:"id"`
  9. Headsign string `bare:"headsign"`
  10. Direction Direction `bare:"direction"`
  11. LineName string `bare:"lineName"`
  12. ScheduleID string `bare:"scheduleID"`
  13. ShapeID string `bare:"shapeID"`
  14. Departures []Departure `bare:"departures"`
  15. }
  16. func (t *Trip) Decode(data []byte) error {
  17. return bare.Unmarshal(data, t)
  18. }
  19. func (t *Trip) Encode() ([]byte, error) {
  20. return bare.Marshal(t)
  21. }
  22. type Vehicle struct {
  23. Id string `bare:"id"`
  24. Capabilities uint16 `bare:"capabilities"`
  25. }
  26. func (t *Vehicle) Decode(data []byte) error {
  27. return bare.Unmarshal(data, t)
  28. }
  29. func (t *Vehicle) Encode() ([]byte, error) {
  30. return bare.Marshal(t)
  31. }
  32. type Departure struct {
  33. StopSequence int `bare:"stopSequence"`
  34. Time uint `bare:"time"`
  35. Pickup Boarding `bare:"pickup"`
  36. Dropoff Boarding `bare:"dropoff"`
  37. StopOffset uint `bare:"stopOffset"`
  38. }
  39. func (t *Departure) Decode(data []byte) error {
  40. return bare.Unmarshal(data, t)
  41. }
  42. func (t *Departure) Encode() ([]byte, error) {
  43. return bare.Marshal(t)
  44. }
  45. type Stop struct {
  46. Id string `bare:"id"`
  47. Code string `bare:"code"`
  48. Name string `bare:"name"`
  49. NodeName string `bare:"nodeName"`
  50. ChangeOptions []ChangeOption `bare:"changeOptions"`
  51. Zone string `bare:"zone"`
  52. Position Position `bare:"position"`
  53. Order map[string]StopOrder `bare:"order"`
  54. Timezone string `bare:"timezone"`
  55. }
  56. func (t *Stop) Decode(data []byte) error {
  57. return bare.Unmarshal(data, t)
  58. }
  59. func (t *Stop) Encode() ([]byte, error) {
  60. return bare.Marshal(t)
  61. }
  62. type ChangeOption struct {
  63. LineName string `bare:"lineName"`
  64. Headsign string `bare:"headsign"`
  65. }
  66. func (t *ChangeOption) Decode(data []byte) error {
  67. return bare.Unmarshal(data, t)
  68. }
  69. func (t *ChangeOption) Encode() ([]byte, error) {
  70. return bare.Marshal(t)
  71. }
  72. type Position struct {
  73. Lat float64 `bare:"lat"`
  74. Lon float64 `bare:"lon"`
  75. }
  76. func (t *Position) Decode(data []byte) error {
  77. return bare.Unmarshal(data, t)
  78. }
  79. func (t *Position) Encode() ([]byte, error) {
  80. return bare.Marshal(t)
  81. }
  82. type LineGraph struct {
  83. StopCodes []string `bare:"stopCodes"`
  84. NextNodes map[int][]int `bare:"nextNodes"`
  85. PrevNodes map[int][]int `bare:"prevNodes"`
  86. }
  87. func (t *LineGraph) Decode(data []byte) error {
  88. return bare.Unmarshal(data, t)
  89. }
  90. func (t *LineGraph) Encode() ([]byte, error) {
  91. return bare.Marshal(t)
  92. }
  93. type StopOrder struct {
  94. TripOffset uint `bare:"tripOffset"`
  95. Sequence int `bare:"sequence"`
  96. }
  97. func (t *StopOrder) Decode(data []byte) error {
  98. return bare.Unmarshal(data, t)
  99. }
  100. func (t *StopOrder) Encode() ([]byte, error) {
  101. return bare.Marshal(t)
  102. }
  103. type Colour struct {
  104. R uint8 `bare:"r"`
  105. G uint8 `bare:"g"`
  106. B uint8 `bare:"b"`
  107. A uint8 `bare:"a"`
  108. }
  109. func (t *Colour) Decode(data []byte) error {
  110. return bare.Unmarshal(data, t)
  111. }
  112. func (t *Colour) Encode() ([]byte, error) {
  113. return bare.Marshal(t)
  114. }
  115. type Line struct {
  116. Id string `bare:"id"`
  117. Name string `bare:"name"`
  118. Colour Colour `bare:"colour"`
  119. Kind LineType `bare:"kind"`
  120. AgencyID string `bare:"agencyID"`
  121. HeadsignsThere []string `bare:"headsignsThere"`
  122. HeadsignsBack []string `bare:"headsignsBack"`
  123. GraphThere LineGraph `bare:"graphThere"`
  124. GraphBack LineGraph `bare:"graphBack"`
  125. }
  126. func (t *Line) Decode(data []byte) error {
  127. return bare.Unmarshal(data, t)
  128. }
  129. func (t *Line) Encode() ([]byte, error) {
  130. return bare.Marshal(t)
  131. }
  132. type FeedInfo struct {
  133. Name string `bare:"name"`
  134. Website string `bare:"website"`
  135. Language string `bare:"language"`
  136. }
  137. func (t *FeedInfo) Decode(data []byte) error {
  138. return bare.Unmarshal(data, t)
  139. }
  140. func (t *FeedInfo) Encode() ([]byte, error) {
  141. return bare.Marshal(t)
  142. }
  143. type Agency struct {
  144. Id string `bare:"id"`
  145. Name string `bare:"name"`
  146. Website string `bare:"website"`
  147. Timezone string `bare:"timezone"`
  148. PhoneNumber string `bare:"phoneNumber"`
  149. Language string `bare:"language"`
  150. Email string `bare:"email"`
  151. FareWebsite string `bare:"fareWebsite"`
  152. }
  153. func (t *Agency) Decode(data []byte) error {
  154. return bare.Unmarshal(data, t)
  155. }
  156. func (t *Agency) Encode() ([]byte, error) {
  157. return bare.Marshal(t)
  158. }
  159. type NameOffset struct {
  160. Name string `bare:"name"`
  161. Offsets []uint `bare:"offsets"`
  162. }
  163. func (t *NameOffset) Decode(data []byte) error {
  164. return bare.Unmarshal(data, t)
  165. }
  166. func (t *NameOffset) Encode() ([]byte, error) {
  167. return bare.Marshal(t)
  168. }
  169. type CodeIndex map[string]uint
  170. func (t *CodeIndex) Decode(data []byte) error {
  171. return bare.Unmarshal(data, t)
  172. }
  173. func (t *CodeIndex) Encode() ([]byte, error) {
  174. return bare.Marshal(t)
  175. }
  176. type Schedule struct {
  177. Id string `bare:"id"`
  178. Weekdays uint8 `bare:"weekdays"`
  179. StartDate string `bare:"startDate"`
  180. EndDate string `bare:"endDate"`
  181. }
  182. func (t *Schedule) Decode(data []byte) error {
  183. return bare.Unmarshal(data, t)
  184. }
  185. func (t *Schedule) Encode() ([]byte, error) {
  186. return bare.Marshal(t)
  187. }
  188. type Direction uint
  189. const (
  190. THERE Direction = 0
  191. BACK Direction = 1
  192. )
  193. func (t Direction) String() string {
  194. switch t {
  195. case THERE:
  196. return "THERE"
  197. case BACK:
  198. return "BACK"
  199. }
  200. panic(errors.New("Invalid Direction value"))
  201. }
  202. type VehicleCapabilities uint
  203. const (
  204. RAMP VehicleCapabilities = 1
  205. LOW_FLOOR VehicleCapabilities = 2
  206. AIR_CONDITIONING VehicleCapabilities = 4
  207. BICYCLE VehicleCapabilities = 8
  208. VOICE_ANNOUNCEMENTS VehicleCapabilities = 16
  209. TICKET_MACHINE VehicleCapabilities = 32
  210. TICKET_SOLD_DRIVER VehicleCapabilities = 64
  211. USB_CHARGING VehicleCapabilities = 128
  212. LOW_FLOOR_PARTIAL VehicleCapabilities = 256
  213. )
  214. func (t VehicleCapabilities) String() string {
  215. switch t {
  216. case RAMP:
  217. return "RAMP"
  218. case LOW_FLOOR:
  219. return "LOW_FLOOR"
  220. case AIR_CONDITIONING:
  221. return "AIR_CONDITIONING"
  222. case BICYCLE:
  223. return "BICYCLE"
  224. case VOICE_ANNOUNCEMENTS:
  225. return "VOICE_ANNOUNCEMENTS"
  226. case TICKET_MACHINE:
  227. return "TICKET_MACHINE"
  228. case TICKET_SOLD_DRIVER:
  229. return "TICKET_SOLD_DRIVER"
  230. case USB_CHARGING:
  231. return "USB_CHARGING"
  232. case LOW_FLOOR_PARTIAL:
  233. return "LOW_FLOOR_PARTIAL"
  234. }
  235. panic(errors.New("Invalid VehicleCapabilities value"))
  236. }
  237. type Boarding uint
  238. const (
  239. REGULAR Boarding = 0
  240. NONE Boarding = 1
  241. BY_PHONE Boarding = 2
  242. BY_DRIVER Boarding = 3
  243. )
  244. func (t Boarding) String() string {
  245. switch t {
  246. case REGULAR:
  247. return "REGULAR"
  248. case NONE:
  249. return "NONE"
  250. case BY_PHONE:
  251. return "BY_PHONE"
  252. case BY_DRIVER:
  253. return "BY_DRIVER"
  254. }
  255. panic(errors.New("Invalid Boarding value"))
  256. }
  257. type LineType uint
  258. const (
  259. TRAM LineType = 0
  260. METRO LineType = 1
  261. RAIL LineType = 2
  262. BUS LineType = 3
  263. FERRY LineType = 4
  264. CABLE_TRAM LineType = 5
  265. CABLE_CAR LineType = 6
  266. FUNICULAR LineType = 7
  267. TROLLEYBUS LineType = 11
  268. MONORAIL LineType = 12
  269. )
  270. func (t LineType) String() string {
  271. switch t {
  272. case TRAM:
  273. return "TRAM"
  274. case METRO:
  275. return "METRO"
  276. case RAIL:
  277. return "RAIL"
  278. case BUS:
  279. return "BUS"
  280. case FERRY:
  281. return "FERRY"
  282. case CABLE_TRAM:
  283. return "CABLE_TRAM"
  284. case CABLE_CAR:
  285. return "CABLE_CAR"
  286. case FUNICULAR:
  287. return "FUNICULAR"
  288. case TROLLEYBUS:
  289. return "TROLLEYBUS"
  290. case MONORAIL:
  291. return "MONORAIL"
  292. }
  293. panic(errors.New("Invalid LineType value"))
  294. }