gitlab.com/evatix-go/core@v1.3.55/coredata/corejson/deserializeFromBytesTo.go (about) 1 package corejson 2 3 import "gitlab.com/evatix-go/core/errcore" 4 5 type deserializeFromBytesTo struct{} 6 7 func (it deserializeFromBytesTo) Strings( 8 rawBytes []byte, 9 ) (lines []string, err error) { 10 err = Deserialize. 11 UsingBytes(rawBytes, &lines) 12 13 return lines, err 14 } 15 16 func (it deserializeFromBytesTo) StringsMust( 17 rawBytes []byte, 18 ) (lines []string) { 19 err := Deserialize.UsingBytes( 20 rawBytes, 21 &lines) 22 23 if err != nil { 24 panic(err) 25 } 26 27 return lines 28 } 29 30 func (it deserializeFromBytesTo) String( 31 rawBytes []byte, 32 ) (line string, err error) { 33 err = Deserialize.UsingBytes( 34 rawBytes, 35 &line) 36 37 return line, err 38 } 39 40 func (it deserializeFromBytesTo) Integer( 41 rawBytes []byte, 42 ) (integer int, err error) { 43 err = Deserialize.UsingBytes( 44 rawBytes, 45 &integer) 46 47 return integer, err 48 } 49 50 func (it deserializeFromBytesTo) IntegerMust( 51 rawBytes []byte, 52 ) (integer int) { 53 err := Deserialize.UsingBytes( 54 rawBytes, 55 &integer) 56 57 errcore.HandleErr(err) 58 59 return integer 60 } 61 62 func (it deserializeFromBytesTo) Integer64( 63 rawBytes []byte, 64 ) (integer64 int64, err error) { 65 err = Deserialize.UsingBytes( 66 rawBytes, 67 &integer64) 68 69 return integer64, err 70 } 71 72 func (it deserializeFromBytesTo) Integer64Must( 73 rawBytes []byte, 74 ) (integer64 int64) { 75 err := Deserialize.UsingBytes( 76 rawBytes, 77 &integer64) 78 79 errcore.HandleErr(err) 80 81 return integer64 82 } 83 84 func (it deserializeFromBytesTo) Integers( 85 rawBytes []byte, 86 ) (integers []int, err error) { 87 err = Deserialize.UsingBytes( 88 rawBytes, 89 &integers) 90 91 return integers, err 92 } 93 94 func (it deserializeFromBytesTo) IntegersMust( 95 rawBytes []byte, 96 ) (integers []int) { 97 err := Deserialize.UsingBytes( 98 rawBytes, 99 &integers) 100 101 if err != nil { 102 panic(err) 103 } 104 105 return integers 106 } 107 108 func (it deserializeFromBytesTo) StringMust( 109 rawBytes []byte, 110 ) (line string) { 111 err := Deserialize.UsingBytes(rawBytes, &line) 112 113 if err != nil { 114 panic(err) 115 } 116 117 return line 118 } 119 120 func (it deserializeFromBytesTo) MapAnyItem( 121 rawBytes []byte, 122 ) (mapAnyItem map[string]interface{}, err error) { 123 err = Deserialize.UsingBytes(rawBytes, &mapAnyItem) 124 125 return mapAnyItem, err 126 } 127 128 func (it deserializeFromBytesTo) MapAnyItemMust( 129 rawBytes []byte, 130 ) (mapAnyItem map[string]interface{}) { 131 err := Deserialize.UsingBytes( 132 rawBytes, 133 &mapAnyItem) 134 135 errcore.HandleErr(err) 136 137 return mapAnyItem 138 } 139 140 func (it deserializeFromBytesTo) MapStringString( 141 rawBytes []byte, 142 ) (mappedItems map[string]string, err error) { 143 err = Deserialize.UsingBytes( 144 rawBytes, 145 &mappedItems) 146 147 return mappedItems, err 148 } 149 150 func (it deserializeFromBytesTo) MapStringStringMust( 151 rawBytes []byte, 152 ) (mappedItems map[string]string) { 153 err := Deserialize.UsingBytes( 154 rawBytes, 155 &mappedItems) 156 157 errcore.HandleErr(err) 158 159 return mappedItems 160 } 161 162 func (it deserializeFromBytesTo) ResultCollection( 163 rawBytes []byte, 164 ) (*ResultsCollection, error) { 165 empty := NewResultsCollection. 166 Empty() 167 err := Deserialize.UsingBytes( 168 rawBytes, 169 empty) 170 171 if err == nil { 172 return empty, nil 173 } 174 175 // has error 176 return nil, err 177 } 178 179 func (it deserializeFromBytesTo) ResultCollectionMust( 180 rawBytes []byte, 181 ) *ResultsCollection { 182 rs, err := it.ResultCollection(rawBytes) 183 errcore.HandleErr(err) 184 185 return rs 186 } 187 188 func (it deserializeFromBytesTo) ResultsPtrCollection( 189 rawBytes []byte, 190 ) (*ResultsPtrCollection, error) { 191 empty := NewResultsPtrCollection. 192 Empty() 193 err := Deserialize.UsingBytes( 194 rawBytes, 195 empty) 196 197 if err == nil { 198 return empty, nil 199 } 200 201 // has error 202 return nil, err 203 } 204 205 func (it deserializeFromBytesTo) ResultsPtrCollectionMust( 206 rawBytes []byte, 207 ) *ResultsPtrCollection { 208 rs, err := it.ResultsPtrCollection( 209 rawBytes) 210 errcore.HandleErr(err) 211 212 return rs 213 } 214 215 func (it deserializerLogic) Result( 216 rawBytes []byte, 217 ) (jsonResult Result, err error) { 218 jsonResult = Empty.Result() 219 err = Deserialize.UsingBytes( 220 rawBytes, jsonResult) 221 222 if err == nil { 223 return jsonResult, jsonResult.MeaningfulError() 224 } 225 226 // has error 227 return jsonResult, errcore.MergeErrors( 228 err, 229 jsonResult.MeaningfulError()) 230 } 231 232 func (it deserializerLogic) ResultMust( 233 rawBytes []byte, 234 ) (jsonResult Result) { 235 jsonResult, err := it.Result(rawBytes) 236 errcore.MustBeEmpty(err) 237 238 return jsonResult 239 } 240 241 func (it deserializerLogic) ResultPtr( 242 rawBytes []byte, 243 ) (jsonResult *Result, err error) { 244 jsonResult = Empty.ResultPtr() 245 err = Deserialize.UsingBytes( 246 rawBytes, jsonResult) 247 248 if err == nil { 249 return jsonResult, jsonResult.MeaningfulError() 250 } 251 252 // has error 253 return nil, errcore.MergeErrors( 254 err, 255 jsonResult.MeaningfulError()) 256 } 257 258 func (it deserializerLogic) ResultPtrMust( 259 rawBytes []byte, 260 ) (jsonResult *Result) { 261 jsonResult, err := it.ResultPtr(rawBytes) 262 errcore.MustBeEmpty(err) 263 264 return jsonResult 265 } 266 267 func (it deserializeFromBytesTo) MapResults( 268 rawBytes []byte, 269 ) (*MapResults, error) { 270 empty := NewMapResults. 271 Empty() 272 err := Deserialize.UsingBytes( 273 rawBytes, 274 empty) 275 276 if err == nil { 277 return empty, nil 278 } 279 280 // has error 281 return nil, err 282 } 283 284 func (it deserializeFromBytesTo) Bytes( 285 rawBytes []byte, 286 ) (nextDeserializedBytes []byte, err error) { 287 err = Deserialize.UsingBytes( 288 rawBytes, 289 &nextDeserializedBytes) 290 291 return nextDeserializedBytes, err 292 } 293 294 func (it deserializeFromBytesTo) BytesMust( 295 rawBytes []byte, 296 ) (nextDeserializedBytes []byte) { 297 err := Deserialize.UsingBytes( 298 rawBytes, 299 &nextDeserializedBytes) 300 errcore.HandleErr(err) 301 302 return nextDeserializedBytes 303 } 304 305 func (it deserializeFromBytesTo) MapResultsMust( 306 rawBytes []byte, 307 ) *MapResults { 308 rs, err := it.MapResults(rawBytes) 309 errcore.HandleErr(err) 310 311 return rs 312 } 313 314 func (it deserializeFromBytesTo) Bool( 315 rawBytes []byte, 316 ) (isResult bool, err error) { 317 err = Deserialize.UsingBytes(rawBytes, &isResult) 318 319 return isResult, err 320 } 321 322 func (it deserializeFromBytesTo) BoolMust( 323 rawBytes []byte, 324 ) (isResult bool) { 325 err := Deserialize.UsingBytes(rawBytes, &isResult) 326 errcore.HandleErr(err) 327 328 return isResult 329 }