opencost_codecs.go 204 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // DO NOT MODIFY
  4. //
  5. // ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻
  6. //
  7. //
  8. // This source file was automatically generated by bingen.
  9. //
  10. ////////////////////////////////////////////////////////////////////////////////
  11. package opencost
  12. import (
  13. "fmt"
  14. util "github.com/opencost/opencost/core/pkg/util"
  15. "reflect"
  16. "strings"
  17. "sync"
  18. "time"
  19. )
  20. const (
  21. // GeneratorPackageName is the package the generator is targetting
  22. GeneratorPackageName string = "opencost"
  23. )
  24. // BinaryTags represent the formatting tag used for specific optimization features
  25. const (
  26. // BinaryTagStringTable is written and/or read prior to the existence of a string
  27. // table (where each index is encoded as a string entry in the resource
  28. BinaryTagStringTable string = "BGST"
  29. )
  30. const (
  31. // DefaultCodecVersion is used for any resources listed in the Default version set
  32. DefaultCodecVersion uint8 = 18
  33. // AssetsCodecVersion is used for any resources listed in the Assets version set
  34. AssetsCodecVersion uint8 = 21
  35. // AllocationCodecVersion is used for any resources listed in the Allocation version set
  36. AllocationCodecVersion uint8 = 24
  37. // CloudCostCodecVersion is used for any resources listed in the CloudCost version set
  38. CloudCostCodecVersion uint8 = 3
  39. // NetworkInsightCodecVersion is used for any resources listed in the NetworkInsight version set
  40. NetworkInsightCodecVersion uint8 = 1
  41. )
  42. //--------------------------------------------------------------------------
  43. // Type Map
  44. //--------------------------------------------------------------------------
  45. // Generated type map for resolving interface implementations to
  46. // to concrete types
  47. var typeMap map[string]reflect.Type = map[string]reflect.Type{
  48. "Allocation": reflect.TypeOf((*Allocation)(nil)).Elem(),
  49. "AllocationProperties": reflect.TypeOf((*AllocationProperties)(nil)).Elem(),
  50. "AllocationSet": reflect.TypeOf((*AllocationSet)(nil)).Elem(),
  51. "AllocationSetRange": reflect.TypeOf((*AllocationSetRange)(nil)).Elem(),
  52. "Any": reflect.TypeOf((*Any)(nil)).Elem(),
  53. "AssetProperties": reflect.TypeOf((*AssetProperties)(nil)).Elem(),
  54. "AssetSet": reflect.TypeOf((*AssetSet)(nil)).Elem(),
  55. "AssetSetRange": reflect.TypeOf((*AssetSetRange)(nil)).Elem(),
  56. "Breakdown": reflect.TypeOf((*Breakdown)(nil)).Elem(),
  57. "Cloud": reflect.TypeOf((*Cloud)(nil)).Elem(),
  58. "CloudCost": reflect.TypeOf((*CloudCost)(nil)).Elem(),
  59. "CloudCostProperties": reflect.TypeOf((*CloudCostProperties)(nil)).Elem(),
  60. "CloudCostSet": reflect.TypeOf((*CloudCostSet)(nil)).Elem(),
  61. "CloudCostSetRange": reflect.TypeOf((*CloudCostSetRange)(nil)).Elem(),
  62. "ClusterManagement": reflect.TypeOf((*ClusterManagement)(nil)).Elem(),
  63. "CostMetric": reflect.TypeOf((*CostMetric)(nil)).Elem(),
  64. "Disk": reflect.TypeOf((*Disk)(nil)).Elem(),
  65. "GPUAllocation": reflect.TypeOf((*GPUAllocation)(nil)).Elem(),
  66. "LbAllocation": reflect.TypeOf((*LbAllocation)(nil)).Elem(),
  67. "LoadBalancer": reflect.TypeOf((*LoadBalancer)(nil)).Elem(),
  68. "Network": reflect.TypeOf((*Network)(nil)).Elem(),
  69. "NetworkDetail": reflect.TypeOf((*NetworkDetail)(nil)).Elem(),
  70. "NetworkInsight": reflect.TypeOf((*NetworkInsight)(nil)).Elem(),
  71. "NetworkInsightSet": reflect.TypeOf((*NetworkInsightSet)(nil)).Elem(),
  72. "Node": reflect.TypeOf((*Node)(nil)).Elem(),
  73. "NodeOverhead": reflect.TypeOf((*NodeOverhead)(nil)).Elem(),
  74. "PVAllocation": reflect.TypeOf((*PVAllocation)(nil)).Elem(),
  75. "PVKey": reflect.TypeOf((*PVKey)(nil)).Elem(),
  76. "RawAllocationOnlyData": reflect.TypeOf((*RawAllocationOnlyData)(nil)).Elem(),
  77. "SharedAsset": reflect.TypeOf((*SharedAsset)(nil)).Elem(),
  78. "Window": reflect.TypeOf((*Window)(nil)).Elem(),
  79. }
  80. //--------------------------------------------------------------------------
  81. // Type Helpers
  82. //--------------------------------------------------------------------------
  83. // isBinaryTag returns true when the first bytes in the provided binary matches the tag
  84. func isBinaryTag(data []byte, tag string) bool {
  85. return string(data[:len(tag)]) == tag
  86. }
  87. // appendBytes combines a and b into a new byte array
  88. func appendBytes(a []byte, b []byte) []byte {
  89. al := len(a)
  90. bl := len(b)
  91. tl := al + bl
  92. // allocate a new byte array for the combined
  93. // use native copy for speedy byte copying
  94. result := make([]byte, tl, tl)
  95. copy(result, a)
  96. copy(result[al:], b)
  97. return result
  98. }
  99. // typeToString determines the basic properties of the type, the qualifier, package path, and
  100. // type name, and returns the qualified type
  101. func typeToString(f interface{}) string {
  102. qual := ""
  103. t := reflect.TypeOf(f)
  104. if t.Kind() == reflect.Ptr {
  105. t = t.Elem()
  106. qual = "*"
  107. }
  108. return fmt.Sprintf("%s%s.%s", qual, t.PkgPath(), t.Name())
  109. }
  110. // resolveType uses the name of a type and returns the package, base type name, and whether
  111. // or not it's a pointer.
  112. func resolveType(t string) (pkg string, name string, isPtr bool) {
  113. isPtr = t[:1] == "*"
  114. if isPtr {
  115. t = t[1:]
  116. }
  117. slashIndex := strings.LastIndex(t, "/")
  118. if slashIndex >= 0 {
  119. t = t[slashIndex+1:]
  120. }
  121. parts := strings.Split(t, ".")
  122. if parts[0] == GeneratorPackageName {
  123. parts[0] = ""
  124. }
  125. pkg = parts[0]
  126. name = parts[1]
  127. return
  128. }
  129. //--------------------------------------------------------------------------
  130. // StringTable
  131. //--------------------------------------------------------------------------
  132. // StringTable maps strings to specific indices for encoding
  133. type StringTable struct {
  134. l *sync.Mutex
  135. indices map[string]int
  136. next int
  137. }
  138. // NewStringTable Creates a new StringTable instance with provided contents
  139. func NewStringTable(contents ...string) *StringTable {
  140. st := &StringTable{
  141. l: new(sync.Mutex),
  142. indices: make(map[string]int),
  143. next: len(contents),
  144. }
  145. for i, entry := range contents {
  146. st.indices[entry] = i
  147. }
  148. return st
  149. }
  150. // AddOrGet atomically retrieves a string entry's index if it exist. Otherwise, it will
  151. // add the entry and return the index.
  152. func (st *StringTable) AddOrGet(s string) int {
  153. st.l.Lock()
  154. defer st.l.Unlock()
  155. if ind, ok := st.indices[s]; ok {
  156. return ind
  157. }
  158. current := st.next
  159. st.next++
  160. st.indices[s] = current
  161. return current
  162. }
  163. // ToSlice Converts the contents to a string array for encoding.
  164. func (st *StringTable) ToSlice() []string {
  165. st.l.Lock()
  166. defer st.l.Unlock()
  167. if st.next == 0 {
  168. return []string{}
  169. }
  170. sl := make([]string, st.next, st.next)
  171. for s, i := range st.indices {
  172. sl[i] = s
  173. }
  174. return sl
  175. }
  176. // ToBytes Converts the contents to a binary encoded representation
  177. func (st *StringTable) ToBytes() []byte {
  178. buff := util.NewBuffer()
  179. buff.WriteBytes([]byte(BinaryTagStringTable)) // bingen table header
  180. strs := st.ToSlice()
  181. buff.WriteInt(len(strs)) // table length
  182. for _, s := range strs {
  183. buff.WriteString(s)
  184. }
  185. return buff.Bytes()
  186. }
  187. //--------------------------------------------------------------------------
  188. // Codec Context
  189. //--------------------------------------------------------------------------
  190. // EncodingContext is a context object passed to the encoders to ensure reuse of buffer
  191. // and table data
  192. type EncodingContext struct {
  193. Buffer *util.Buffer
  194. Table *StringTable
  195. }
  196. // IsStringTable returns true if the table is available
  197. func (ec *EncodingContext) IsStringTable() bool {
  198. return ec.Table != nil
  199. }
  200. // DecodingContext is a context object passed to the decoders to ensure parent objects
  201. // reuse as much data as possible
  202. type DecodingContext struct {
  203. Buffer *util.Buffer
  204. Table []string
  205. }
  206. // IsStringTable returns true if the table is available
  207. func (dc *DecodingContext) IsStringTable() bool {
  208. return len(dc.Table) > 0
  209. }
  210. //--------------------------------------------------------------------------
  211. // Binary Codec
  212. //--------------------------------------------------------------------------
  213. // BinEncoder is an encoding interface which defines a context based marshal contract.
  214. type BinEncoder interface {
  215. MarshalBinaryWithContext(*EncodingContext) error
  216. }
  217. // BinDecoder is a decoding interface which defines a context based unmarshal contract.
  218. type BinDecoder interface {
  219. UnmarshalBinaryWithContext(*DecodingContext) error
  220. }
  221. //--------------------------------------------------------------------------
  222. // Allocation
  223. //--------------------------------------------------------------------------
  224. // MarshalBinary serializes the internal properties of this Allocation instance
  225. // into a byte array
  226. func (target *Allocation) MarshalBinary() (data []byte, err error) {
  227. ctx := &EncodingContext{
  228. Buffer: util.NewBuffer(),
  229. Table: nil,
  230. }
  231. e := target.MarshalBinaryWithContext(ctx)
  232. if e != nil {
  233. return nil, e
  234. }
  235. encBytes := ctx.Buffer.Bytes()
  236. return encBytes, nil
  237. }
  238. // MarshalBinaryWithContext serializes the internal properties of this Allocation instance
  239. // into a byte array leveraging a predefined context.
  240. func (target *Allocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  241. // panics are recovered and propagated as errors
  242. defer func() {
  243. if r := recover(); r != nil {
  244. if e, ok := r.(error); ok {
  245. err = e
  246. } else if s, ok := r.(string); ok {
  247. err = fmt.Errorf("Unexpected panic: %s", s)
  248. } else {
  249. err = fmt.Errorf("Unexpected panic: %+v", r)
  250. }
  251. }
  252. }()
  253. buff := ctx.Buffer
  254. buff.WriteUInt8(AllocationCodecVersion) // version
  255. if ctx.IsStringTable() {
  256. a := ctx.Table.AddOrGet(target.Name)
  257. buff.WriteInt(a) // write table index
  258. } else {
  259. buff.WriteString(target.Name) // write string
  260. }
  261. if target.Properties == nil {
  262. buff.WriteUInt8(uint8(0)) // write nil byte
  263. } else {
  264. buff.WriteUInt8(uint8(1)) // write non-nil byte
  265. // --- [begin][write][struct](AllocationProperties) ---
  266. buff.WriteInt(0) // [compatibility, unused]
  267. errA := target.Properties.MarshalBinaryWithContext(ctx)
  268. if errA != nil {
  269. return errA
  270. }
  271. // --- [end][write][struct](AllocationProperties) ---
  272. }
  273. // --- [begin][write][struct](Window) ---
  274. buff.WriteInt(0) // [compatibility, unused]
  275. errB := target.Window.MarshalBinaryWithContext(ctx)
  276. if errB != nil {
  277. return errB
  278. }
  279. // --- [end][write][struct](Window) ---
  280. // --- [begin][write][reference](time.Time) ---
  281. b, errC := target.Start.MarshalBinary()
  282. if errC != nil {
  283. return errC
  284. }
  285. buff.WriteInt(len(b))
  286. buff.WriteBytes(b)
  287. // --- [end][write][reference](time.Time) ---
  288. // --- [begin][write][reference](time.Time) ---
  289. c, errD := target.End.MarshalBinary()
  290. if errD != nil {
  291. return errD
  292. }
  293. buff.WriteInt(len(c))
  294. buff.WriteBytes(c)
  295. // --- [end][write][reference](time.Time) ---
  296. buff.WriteFloat64(target.CPUCoreHours) // write float64
  297. buff.WriteFloat64(target.CPUCoreRequestAverage) // write float64
  298. buff.WriteFloat64(target.CPUCoreUsageAverage) // write float64
  299. buff.WriteFloat64(target.CPUCost) // write float64
  300. buff.WriteFloat64(target.CPUCostAdjustment) // write float64
  301. buff.WriteFloat64(target.GPUHours) // write float64
  302. buff.WriteFloat64(target.GPUCost) // write float64
  303. buff.WriteFloat64(target.GPUCostAdjustment) // write float64
  304. buff.WriteFloat64(target.NetworkTransferBytes) // write float64
  305. buff.WriteFloat64(target.NetworkReceiveBytes) // write float64
  306. buff.WriteFloat64(target.NetworkCost) // write float64
  307. buff.WriteFloat64(target.NetworkCrossZoneCost) // write float64
  308. buff.WriteFloat64(target.NetworkCrossRegionCost) // write float64
  309. buff.WriteFloat64(target.NetworkInternetCost) // write float64
  310. buff.WriteFloat64(target.NetworkCostAdjustment) // write float64
  311. buff.WriteFloat64(target.LoadBalancerCost) // write float64
  312. buff.WriteFloat64(target.LoadBalancerCostAdjustment) // write float64
  313. // --- [begin][write][alias](PVAllocations) ---
  314. if map[PVKey]*PVAllocation(target.PVs) == nil {
  315. buff.WriteUInt8(uint8(0)) // write nil byte
  316. } else {
  317. buff.WriteUInt8(uint8(1)) // write non-nil byte
  318. // --- [begin][write][map](map[PVKey]*PVAllocation) ---
  319. buff.WriteInt(len(map[PVKey]*PVAllocation(target.PVs))) // map length
  320. for v, z := range map[PVKey]*PVAllocation(target.PVs) {
  321. // --- [begin][write][struct](PVKey) ---
  322. buff.WriteInt(0) // [compatibility, unused]
  323. errE := v.MarshalBinaryWithContext(ctx)
  324. if errE != nil {
  325. return errE
  326. }
  327. // --- [end][write][struct](PVKey) ---
  328. if z == nil {
  329. buff.WriteUInt8(uint8(0)) // write nil byte
  330. } else {
  331. buff.WriteUInt8(uint8(1)) // write non-nil byte
  332. // --- [begin][write][struct](PVAllocation) ---
  333. buff.WriteInt(0) // [compatibility, unused]
  334. errF := z.MarshalBinaryWithContext(ctx)
  335. if errF != nil {
  336. return errF
  337. }
  338. // --- [end][write][struct](PVAllocation) ---
  339. }
  340. }
  341. // --- [end][write][map](map[PVKey]*PVAllocation) ---
  342. }
  343. // --- [end][write][alias](PVAllocations) ---
  344. buff.WriteFloat64(target.PVCostAdjustment) // write float64
  345. buff.WriteFloat64(target.RAMByteHours) // write float64
  346. buff.WriteFloat64(target.RAMBytesRequestAverage) // write float64
  347. buff.WriteFloat64(target.RAMBytesUsageAverage) // write float64
  348. buff.WriteFloat64(target.RAMCost) // write float64
  349. buff.WriteFloat64(target.RAMCostAdjustment) // write float64
  350. buff.WriteFloat64(target.SharedCost) // write float64
  351. buff.WriteFloat64(target.ExternalCost) // write float64
  352. if target.RawAllocationOnly == nil {
  353. buff.WriteUInt8(uint8(0)) // write nil byte
  354. } else {
  355. buff.WriteUInt8(uint8(1)) // write non-nil byte
  356. // --- [begin][write][struct](RawAllocationOnlyData) ---
  357. buff.WriteInt(0) // [compatibility, unused]
  358. errG := target.RawAllocationOnly.MarshalBinaryWithContext(ctx)
  359. if errG != nil {
  360. return errG
  361. }
  362. // --- [end][write][struct](RawAllocationOnlyData) ---
  363. }
  364. // --- [begin][write][alias](LbAllocations) ---
  365. if map[string]*LbAllocation(target.LoadBalancers) == nil {
  366. buff.WriteUInt8(uint8(0)) // write nil byte
  367. } else {
  368. buff.WriteUInt8(uint8(1)) // write non-nil byte
  369. // --- [begin][write][map](map[string]*LbAllocation) ---
  370. buff.WriteInt(len(map[string]*LbAllocation(target.LoadBalancers))) // map length
  371. for vv, zz := range map[string]*LbAllocation(target.LoadBalancers) {
  372. if ctx.IsStringTable() {
  373. d := ctx.Table.AddOrGet(vv)
  374. buff.WriteInt(d) // write table index
  375. } else {
  376. buff.WriteString(vv) // write string
  377. }
  378. if zz == nil {
  379. buff.WriteUInt8(uint8(0)) // write nil byte
  380. } else {
  381. buff.WriteUInt8(uint8(1)) // write non-nil byte
  382. // --- [begin][write][struct](LbAllocation) ---
  383. buff.WriteInt(0) // [compatibility, unused]
  384. errH := zz.MarshalBinaryWithContext(ctx)
  385. if errH != nil {
  386. return errH
  387. }
  388. // --- [end][write][struct](LbAllocation) ---
  389. }
  390. }
  391. // --- [end][write][map](map[string]*LbAllocation) ---
  392. }
  393. // --- [end][write][alias](LbAllocations) ---
  394. buff.WriteFloat64(target.deprecatedGPURequestAverage) // write float64
  395. buff.WriteFloat64(target.deprecatedGPUUsageAverage) // write float64
  396. if target.GPUAllocation == nil {
  397. buff.WriteUInt8(uint8(0)) // write nil byte
  398. } else {
  399. buff.WriteUInt8(uint8(1)) // write non-nil byte
  400. // --- [begin][write][struct](GPUAllocation) ---
  401. buff.WriteInt(0) // [compatibility, unused]
  402. errI := target.GPUAllocation.MarshalBinaryWithContext(ctx)
  403. if errI != nil {
  404. return errI
  405. }
  406. // --- [end][write][struct](GPUAllocation) ---
  407. }
  408. buff.WriteFloat64(target.CPUCoreLimitAverage) // write float64
  409. buff.WriteFloat64(target.RAMBytesLimitAverage) // write float64
  410. return nil
  411. }
  412. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  413. // the Allocation type
  414. func (target *Allocation) UnmarshalBinary(data []byte) error {
  415. var table []string
  416. buff := util.NewBufferFromBytes(data)
  417. // string table header validation
  418. if isBinaryTag(data, BinaryTagStringTable) {
  419. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  420. tl := buff.ReadInt() // table length
  421. if tl > 0 {
  422. table = make([]string, tl, tl)
  423. for i := 0; i < tl; i++ {
  424. table[i] = buff.ReadString()
  425. }
  426. }
  427. }
  428. ctx := &DecodingContext{
  429. Buffer: buff,
  430. Table: table,
  431. }
  432. err := target.UnmarshalBinaryWithContext(ctx)
  433. if err != nil {
  434. return err
  435. }
  436. return nil
  437. }
  438. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  439. // the Allocation type
  440. func (target *Allocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  441. // panics are recovered and propagated as errors
  442. defer func() {
  443. if r := recover(); r != nil {
  444. if e, ok := r.(error); ok {
  445. err = e
  446. } else if s, ok := r.(string); ok {
  447. err = fmt.Errorf("Unexpected panic: %s", s)
  448. } else {
  449. err = fmt.Errorf("Unexpected panic: %+v", r)
  450. }
  451. }
  452. }()
  453. buff := ctx.Buffer
  454. version := buff.ReadUInt8()
  455. if version > AllocationCodecVersion {
  456. return fmt.Errorf("Invalid Version Unmarshaling Allocation. Expected %d or less, got %d", AllocationCodecVersion, version)
  457. }
  458. var b string
  459. if ctx.IsStringTable() {
  460. c := buff.ReadInt() // read string index
  461. b = ctx.Table[c]
  462. } else {
  463. b = buff.ReadString() // read string
  464. }
  465. a := b
  466. target.Name = a
  467. if buff.ReadUInt8() == uint8(0) {
  468. target.Properties = nil
  469. } else {
  470. // --- [begin][read][struct](AllocationProperties) ---
  471. d := &AllocationProperties{}
  472. buff.ReadInt() // [compatibility, unused]
  473. errA := d.UnmarshalBinaryWithContext(ctx)
  474. if errA != nil {
  475. return errA
  476. }
  477. target.Properties = d
  478. // --- [end][read][struct](AllocationProperties) ---
  479. }
  480. // --- [begin][read][struct](Window) ---
  481. e := &Window{}
  482. buff.ReadInt() // [compatibility, unused]
  483. errB := e.UnmarshalBinaryWithContext(ctx)
  484. if errB != nil {
  485. return errB
  486. }
  487. target.Window = *e
  488. // --- [end][read][struct](Window) ---
  489. // --- [begin][read][reference](time.Time) ---
  490. f := &time.Time{}
  491. g := buff.ReadInt() // byte array length
  492. h := buff.ReadBytes(g) // byte array
  493. errC := f.UnmarshalBinary(h)
  494. if errC != nil {
  495. return errC
  496. }
  497. target.Start = *f
  498. // --- [end][read][reference](time.Time) ---
  499. // --- [begin][read][reference](time.Time) ---
  500. k := &time.Time{}
  501. l := buff.ReadInt() // byte array length
  502. m := buff.ReadBytes(l) // byte array
  503. errD := k.UnmarshalBinary(m)
  504. if errD != nil {
  505. return errD
  506. }
  507. target.End = *k
  508. // --- [end][read][reference](time.Time) ---
  509. n := buff.ReadFloat64() // read float64
  510. target.CPUCoreHours = n
  511. o := buff.ReadFloat64() // read float64
  512. target.CPUCoreRequestAverage = o
  513. p := buff.ReadFloat64() // read float64
  514. target.CPUCoreUsageAverage = p
  515. q := buff.ReadFloat64() // read float64
  516. target.CPUCost = q
  517. r := buff.ReadFloat64() // read float64
  518. target.CPUCostAdjustment = r
  519. s := buff.ReadFloat64() // read float64
  520. target.GPUHours = s
  521. t := buff.ReadFloat64() // read float64
  522. target.GPUCost = t
  523. u := buff.ReadFloat64() // read float64
  524. target.GPUCostAdjustment = u
  525. w := buff.ReadFloat64() // read float64
  526. target.NetworkTransferBytes = w
  527. x := buff.ReadFloat64() // read float64
  528. target.NetworkReceiveBytes = x
  529. y := buff.ReadFloat64() // read float64
  530. target.NetworkCost = y
  531. // field version check
  532. if uint8(16) <= version {
  533. aa := buff.ReadFloat64() // read float64
  534. target.NetworkCrossZoneCost = aa
  535. } else {
  536. target.NetworkCrossZoneCost = float64(0) // default
  537. }
  538. // field version check
  539. if uint8(16) <= version {
  540. bb := buff.ReadFloat64() // read float64
  541. target.NetworkCrossRegionCost = bb
  542. } else {
  543. target.NetworkCrossRegionCost = float64(0) // default
  544. }
  545. // field version check
  546. if uint8(16) <= version {
  547. cc := buff.ReadFloat64() // read float64
  548. target.NetworkInternetCost = cc
  549. } else {
  550. target.NetworkInternetCost = float64(0) // default
  551. }
  552. dd := buff.ReadFloat64() // read float64
  553. target.NetworkCostAdjustment = dd
  554. ee := buff.ReadFloat64() // read float64
  555. target.LoadBalancerCost = ee
  556. ff := buff.ReadFloat64() // read float64
  557. target.LoadBalancerCostAdjustment = ff
  558. // --- [begin][read][alias](PVAllocations) ---
  559. var gg map[PVKey]*PVAllocation
  560. if buff.ReadUInt8() == uint8(0) {
  561. gg = nil
  562. } else {
  563. // --- [begin][read][map](map[PVKey]*PVAllocation) ---
  564. kk := buff.ReadInt() // map len
  565. hh := make(map[PVKey]*PVAllocation, kk)
  566. for i := 0; i < kk; i++ {
  567. // --- [begin][read][struct](PVKey) ---
  568. ll := &PVKey{}
  569. buff.ReadInt() // [compatibility, unused]
  570. errE := ll.UnmarshalBinaryWithContext(ctx)
  571. if errE != nil {
  572. return errE
  573. }
  574. v := *ll
  575. // --- [end][read][struct](PVKey) ---
  576. var z *PVAllocation
  577. if buff.ReadUInt8() == uint8(0) {
  578. z = nil
  579. } else {
  580. // --- [begin][read][struct](PVAllocation) ---
  581. mm := &PVAllocation{}
  582. buff.ReadInt() // [compatibility, unused]
  583. errF := mm.UnmarshalBinaryWithContext(ctx)
  584. if errF != nil {
  585. return errF
  586. }
  587. z = mm
  588. // --- [end][read][struct](PVAllocation) ---
  589. }
  590. hh[v] = z
  591. }
  592. gg = hh
  593. // --- [end][read][map](map[PVKey]*PVAllocation) ---
  594. }
  595. target.PVs = PVAllocations(gg)
  596. // --- [end][read][alias](PVAllocations) ---
  597. nn := buff.ReadFloat64() // read float64
  598. target.PVCostAdjustment = nn
  599. oo := buff.ReadFloat64() // read float64
  600. target.RAMByteHours = oo
  601. pp := buff.ReadFloat64() // read float64
  602. target.RAMBytesRequestAverage = pp
  603. qq := buff.ReadFloat64() // read float64
  604. target.RAMBytesUsageAverage = qq
  605. rr := buff.ReadFloat64() // read float64
  606. target.RAMCost = rr
  607. ss := buff.ReadFloat64() // read float64
  608. target.RAMCostAdjustment = ss
  609. tt := buff.ReadFloat64() // read float64
  610. target.SharedCost = tt
  611. uu := buff.ReadFloat64() // read float64
  612. target.ExternalCost = uu
  613. if buff.ReadUInt8() == uint8(0) {
  614. target.RawAllocationOnly = nil
  615. } else {
  616. // --- [begin][read][struct](RawAllocationOnlyData) ---
  617. ww := &RawAllocationOnlyData{}
  618. buff.ReadInt() // [compatibility, unused]
  619. errG := ww.UnmarshalBinaryWithContext(ctx)
  620. if errG != nil {
  621. return errG
  622. }
  623. target.RawAllocationOnly = ww
  624. // --- [end][read][struct](RawAllocationOnlyData) ---
  625. }
  626. // field version check
  627. if uint8(18) <= version {
  628. // --- [begin][read][alias](LbAllocations) ---
  629. var xx map[string]*LbAllocation
  630. if buff.ReadUInt8() == uint8(0) {
  631. xx = nil
  632. } else {
  633. // --- [begin][read][map](map[string]*LbAllocation) ---
  634. aaa := buff.ReadInt() // map len
  635. yy := make(map[string]*LbAllocation, aaa)
  636. for j := 0; j < aaa; j++ {
  637. var vv string
  638. var ccc string
  639. if ctx.IsStringTable() {
  640. ddd := buff.ReadInt() // read string index
  641. ccc = ctx.Table[ddd]
  642. } else {
  643. ccc = buff.ReadString() // read string
  644. }
  645. bbb := ccc
  646. vv = bbb
  647. var zz *LbAllocation
  648. if buff.ReadUInt8() == uint8(0) {
  649. zz = nil
  650. } else {
  651. // --- [begin][read][struct](LbAllocation) ---
  652. eee := &LbAllocation{}
  653. buff.ReadInt() // [compatibility, unused]
  654. errH := eee.UnmarshalBinaryWithContext(ctx)
  655. if errH != nil {
  656. return errH
  657. }
  658. zz = eee
  659. // --- [end][read][struct](LbAllocation) ---
  660. }
  661. yy[vv] = zz
  662. }
  663. xx = yy
  664. // --- [end][read][map](map[string]*LbAllocation) ---
  665. }
  666. target.LoadBalancers = LbAllocations(xx)
  667. // --- [end][read][alias](LbAllocations) ---
  668. } else {
  669. }
  670. // field version check
  671. if uint8(22) <= version {
  672. fff := buff.ReadFloat64() // read float64
  673. target.deprecatedGPURequestAverage = fff
  674. } else {
  675. target.deprecatedGPURequestAverage = float64(0) // default
  676. }
  677. // field version check
  678. if uint8(22) <= version {
  679. ggg := buff.ReadFloat64() // read float64
  680. target.deprecatedGPUUsageAverage = ggg
  681. } else {
  682. target.deprecatedGPUUsageAverage = float64(0) // default
  683. }
  684. // field version check
  685. if uint8(23) <= version {
  686. if buff.ReadUInt8() == uint8(0) {
  687. target.GPUAllocation = nil
  688. } else {
  689. // --- [begin][read][struct](GPUAllocation) ---
  690. hhh := &GPUAllocation{}
  691. buff.ReadInt() // [compatibility, unused]
  692. errI := hhh.UnmarshalBinaryWithContext(ctx)
  693. if errI != nil {
  694. return errI
  695. }
  696. target.GPUAllocation = hhh
  697. // --- [end][read][struct](GPUAllocation) ---
  698. }
  699. } else {
  700. target.GPUAllocation = nil
  701. }
  702. // field version check
  703. if uint8(24) <= version {
  704. kkk := buff.ReadFloat64() // read float64
  705. target.CPUCoreLimitAverage = kkk
  706. } else {
  707. target.CPUCoreLimitAverage = float64(0) // default
  708. }
  709. // field version check
  710. if uint8(24) <= version {
  711. lll := buff.ReadFloat64() // read float64
  712. target.RAMBytesLimitAverage = lll
  713. } else {
  714. target.RAMBytesLimitAverage = float64(0) // default
  715. }
  716. // execute migration func if version delta detected
  717. if version != AllocationCodecVersion {
  718. migrateAllocation(target, version, AllocationCodecVersion)
  719. }
  720. return nil
  721. }
  722. //--------------------------------------------------------------------------
  723. // AllocationProperties
  724. //--------------------------------------------------------------------------
  725. // MarshalBinary serializes the internal properties of this AllocationProperties instance
  726. // into a byte array
  727. func (target *AllocationProperties) MarshalBinary() (data []byte, err error) {
  728. ctx := &EncodingContext{
  729. Buffer: util.NewBuffer(),
  730. Table: nil,
  731. }
  732. e := target.MarshalBinaryWithContext(ctx)
  733. if e != nil {
  734. return nil, e
  735. }
  736. encBytes := ctx.Buffer.Bytes()
  737. return encBytes, nil
  738. }
  739. // MarshalBinaryWithContext serializes the internal properties of this AllocationProperties instance
  740. // into a byte array leveraging a predefined context.
  741. func (target *AllocationProperties) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  742. // panics are recovered and propagated as errors
  743. defer func() {
  744. if r := recover(); r != nil {
  745. if e, ok := r.(error); ok {
  746. err = e
  747. } else if s, ok := r.(string); ok {
  748. err = fmt.Errorf("Unexpected panic: %s", s)
  749. } else {
  750. err = fmt.Errorf("Unexpected panic: %+v", r)
  751. }
  752. }
  753. }()
  754. buff := ctx.Buffer
  755. buff.WriteUInt8(AllocationCodecVersion) // version
  756. if ctx.IsStringTable() {
  757. a := ctx.Table.AddOrGet(target.Cluster)
  758. buff.WriteInt(a) // write table index
  759. } else {
  760. buff.WriteString(target.Cluster) // write string
  761. }
  762. if ctx.IsStringTable() {
  763. b := ctx.Table.AddOrGet(target.Node)
  764. buff.WriteInt(b) // write table index
  765. } else {
  766. buff.WriteString(target.Node) // write string
  767. }
  768. if ctx.IsStringTable() {
  769. c := ctx.Table.AddOrGet(target.Container)
  770. buff.WriteInt(c) // write table index
  771. } else {
  772. buff.WriteString(target.Container) // write string
  773. }
  774. if ctx.IsStringTable() {
  775. d := ctx.Table.AddOrGet(target.Controller)
  776. buff.WriteInt(d) // write table index
  777. } else {
  778. buff.WriteString(target.Controller) // write string
  779. }
  780. if ctx.IsStringTable() {
  781. e := ctx.Table.AddOrGet(target.ControllerKind)
  782. buff.WriteInt(e) // write table index
  783. } else {
  784. buff.WriteString(target.ControllerKind) // write string
  785. }
  786. if ctx.IsStringTable() {
  787. f := ctx.Table.AddOrGet(target.Namespace)
  788. buff.WriteInt(f) // write table index
  789. } else {
  790. buff.WriteString(target.Namespace) // write string
  791. }
  792. if ctx.IsStringTable() {
  793. g := ctx.Table.AddOrGet(target.Pod)
  794. buff.WriteInt(g) // write table index
  795. } else {
  796. buff.WriteString(target.Pod) // write string
  797. }
  798. if target.Services == nil {
  799. buff.WriteUInt8(uint8(0)) // write nil byte
  800. } else {
  801. buff.WriteUInt8(uint8(1)) // write non-nil byte
  802. // --- [begin][write][slice]([]string) ---
  803. buff.WriteInt(len(target.Services)) // array length
  804. for i := 0; i < len(target.Services); i++ {
  805. if ctx.IsStringTable() {
  806. h := ctx.Table.AddOrGet(target.Services[i])
  807. buff.WriteInt(h) // write table index
  808. } else {
  809. buff.WriteString(target.Services[i]) // write string
  810. }
  811. }
  812. // --- [end][write][slice]([]string) ---
  813. }
  814. if ctx.IsStringTable() {
  815. k := ctx.Table.AddOrGet(target.ProviderID)
  816. buff.WriteInt(k) // write table index
  817. } else {
  818. buff.WriteString(target.ProviderID) // write string
  819. }
  820. // --- [begin][write][alias](AllocationLabels) ---
  821. if map[string]string(target.Labels) == nil {
  822. buff.WriteUInt8(uint8(0)) // write nil byte
  823. } else {
  824. buff.WriteUInt8(uint8(1)) // write non-nil byte
  825. // --- [begin][write][map](map[string]string) ---
  826. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  827. for v, z := range map[string]string(target.Labels) {
  828. if ctx.IsStringTable() {
  829. l := ctx.Table.AddOrGet(v)
  830. buff.WriteInt(l) // write table index
  831. } else {
  832. buff.WriteString(v) // write string
  833. }
  834. if ctx.IsStringTable() {
  835. m := ctx.Table.AddOrGet(z)
  836. buff.WriteInt(m) // write table index
  837. } else {
  838. buff.WriteString(z) // write string
  839. }
  840. }
  841. // --- [end][write][map](map[string]string) ---
  842. }
  843. // --- [end][write][alias](AllocationLabels) ---
  844. // --- [begin][write][alias](AllocationAnnotations) ---
  845. if map[string]string(target.Annotations) == nil {
  846. buff.WriteUInt8(uint8(0)) // write nil byte
  847. } else {
  848. buff.WriteUInt8(uint8(1)) // write non-nil byte
  849. // --- [begin][write][map](map[string]string) ---
  850. buff.WriteInt(len(map[string]string(target.Annotations))) // map length
  851. for vv, zz := range map[string]string(target.Annotations) {
  852. if ctx.IsStringTable() {
  853. n := ctx.Table.AddOrGet(vv)
  854. buff.WriteInt(n) // write table index
  855. } else {
  856. buff.WriteString(vv) // write string
  857. }
  858. if ctx.IsStringTable() {
  859. o := ctx.Table.AddOrGet(zz)
  860. buff.WriteInt(o) // write table index
  861. } else {
  862. buff.WriteString(zz) // write string
  863. }
  864. }
  865. // --- [end][write][map](map[string]string) ---
  866. }
  867. // --- [end][write][alias](AllocationAnnotations) ---
  868. // --- [begin][write][alias](AllocationLabels) ---
  869. if map[string]string(target.NamespaceLabels) == nil {
  870. buff.WriteUInt8(uint8(0)) // write nil byte
  871. } else {
  872. buff.WriteUInt8(uint8(1)) // write non-nil byte
  873. // --- [begin][write][map](map[string]string) ---
  874. buff.WriteInt(len(map[string]string(target.NamespaceLabels))) // map length
  875. for vvv, zzz := range map[string]string(target.NamespaceLabels) {
  876. if ctx.IsStringTable() {
  877. p := ctx.Table.AddOrGet(vvv)
  878. buff.WriteInt(p) // write table index
  879. } else {
  880. buff.WriteString(vvv) // write string
  881. }
  882. if ctx.IsStringTable() {
  883. q := ctx.Table.AddOrGet(zzz)
  884. buff.WriteInt(q) // write table index
  885. } else {
  886. buff.WriteString(zzz) // write string
  887. }
  888. }
  889. // --- [end][write][map](map[string]string) ---
  890. }
  891. // --- [end][write][alias](AllocationLabels) ---
  892. // --- [begin][write][alias](AllocationAnnotations) ---
  893. if map[string]string(target.NamespaceAnnotations) == nil {
  894. buff.WriteUInt8(uint8(0)) // write nil byte
  895. } else {
  896. buff.WriteUInt8(uint8(1)) // write non-nil byte
  897. // --- [begin][write][map](map[string]string) ---
  898. buff.WriteInt(len(map[string]string(target.NamespaceAnnotations))) // map length
  899. for vvvv, zzzz := range map[string]string(target.NamespaceAnnotations) {
  900. if ctx.IsStringTable() {
  901. r := ctx.Table.AddOrGet(vvvv)
  902. buff.WriteInt(r) // write table index
  903. } else {
  904. buff.WriteString(vvvv) // write string
  905. }
  906. if ctx.IsStringTable() {
  907. s := ctx.Table.AddOrGet(zzzz)
  908. buff.WriteInt(s) // write table index
  909. } else {
  910. buff.WriteString(zzzz) // write string
  911. }
  912. }
  913. // --- [end][write][map](map[string]string) ---
  914. }
  915. // --- [end][write][alias](AllocationAnnotations) ---
  916. return nil
  917. }
  918. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  919. // the AllocationProperties type
  920. func (target *AllocationProperties) UnmarshalBinary(data []byte) error {
  921. var table []string
  922. buff := util.NewBufferFromBytes(data)
  923. // string table header validation
  924. if isBinaryTag(data, BinaryTagStringTable) {
  925. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  926. tl := buff.ReadInt() // table length
  927. if tl > 0 {
  928. table = make([]string, tl, tl)
  929. for i := 0; i < tl; i++ {
  930. table[i] = buff.ReadString()
  931. }
  932. }
  933. }
  934. ctx := &DecodingContext{
  935. Buffer: buff,
  936. Table: table,
  937. }
  938. err := target.UnmarshalBinaryWithContext(ctx)
  939. if err != nil {
  940. return err
  941. }
  942. return nil
  943. }
  944. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  945. // the AllocationProperties type
  946. func (target *AllocationProperties) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  947. // panics are recovered and propagated as errors
  948. defer func() {
  949. if r := recover(); r != nil {
  950. if e, ok := r.(error); ok {
  951. err = e
  952. } else if s, ok := r.(string); ok {
  953. err = fmt.Errorf("Unexpected panic: %s", s)
  954. } else {
  955. err = fmt.Errorf("Unexpected panic: %+v", r)
  956. }
  957. }
  958. }()
  959. buff := ctx.Buffer
  960. version := buff.ReadUInt8()
  961. if version > AllocationCodecVersion {
  962. return fmt.Errorf("Invalid Version Unmarshaling AllocationProperties. Expected %d or less, got %d", AllocationCodecVersion, version)
  963. }
  964. var b string
  965. if ctx.IsStringTable() {
  966. c := buff.ReadInt() // read string index
  967. b = ctx.Table[c]
  968. } else {
  969. b = buff.ReadString() // read string
  970. }
  971. a := b
  972. target.Cluster = a
  973. var e string
  974. if ctx.IsStringTable() {
  975. f := buff.ReadInt() // read string index
  976. e = ctx.Table[f]
  977. } else {
  978. e = buff.ReadString() // read string
  979. }
  980. d := e
  981. target.Node = d
  982. var h string
  983. if ctx.IsStringTable() {
  984. k := buff.ReadInt() // read string index
  985. h = ctx.Table[k]
  986. } else {
  987. h = buff.ReadString() // read string
  988. }
  989. g := h
  990. target.Container = g
  991. var m string
  992. if ctx.IsStringTable() {
  993. n := buff.ReadInt() // read string index
  994. m = ctx.Table[n]
  995. } else {
  996. m = buff.ReadString() // read string
  997. }
  998. l := m
  999. target.Controller = l
  1000. var p string
  1001. if ctx.IsStringTable() {
  1002. q := buff.ReadInt() // read string index
  1003. p = ctx.Table[q]
  1004. } else {
  1005. p = buff.ReadString() // read string
  1006. }
  1007. o := p
  1008. target.ControllerKind = o
  1009. var s string
  1010. if ctx.IsStringTable() {
  1011. t := buff.ReadInt() // read string index
  1012. s = ctx.Table[t]
  1013. } else {
  1014. s = buff.ReadString() // read string
  1015. }
  1016. r := s
  1017. target.Namespace = r
  1018. var w string
  1019. if ctx.IsStringTable() {
  1020. x := buff.ReadInt() // read string index
  1021. w = ctx.Table[x]
  1022. } else {
  1023. w = buff.ReadString() // read string
  1024. }
  1025. u := w
  1026. target.Pod = u
  1027. if buff.ReadUInt8() == uint8(0) {
  1028. target.Services = nil
  1029. } else {
  1030. // --- [begin][read][slice]([]string) ---
  1031. aa := buff.ReadInt() // array len
  1032. y := make([]string, aa)
  1033. for i := 0; i < aa; i++ {
  1034. var bb string
  1035. var dd string
  1036. if ctx.IsStringTable() {
  1037. ee := buff.ReadInt() // read string index
  1038. dd = ctx.Table[ee]
  1039. } else {
  1040. dd = buff.ReadString() // read string
  1041. }
  1042. cc := dd
  1043. bb = cc
  1044. y[i] = bb
  1045. }
  1046. target.Services = y
  1047. // --- [end][read][slice]([]string) ---
  1048. }
  1049. var gg string
  1050. if ctx.IsStringTable() {
  1051. hh := buff.ReadInt() // read string index
  1052. gg = ctx.Table[hh]
  1053. } else {
  1054. gg = buff.ReadString() // read string
  1055. }
  1056. ff := gg
  1057. target.ProviderID = ff
  1058. // --- [begin][read][alias](AllocationLabels) ---
  1059. var kk map[string]string
  1060. if buff.ReadUInt8() == uint8(0) {
  1061. kk = nil
  1062. } else {
  1063. // --- [begin][read][map](map[string]string) ---
  1064. mm := buff.ReadInt() // map len
  1065. ll := make(map[string]string, mm)
  1066. for j := 0; j < mm; j++ {
  1067. var v string
  1068. var oo string
  1069. if ctx.IsStringTable() {
  1070. pp := buff.ReadInt() // read string index
  1071. oo = ctx.Table[pp]
  1072. } else {
  1073. oo = buff.ReadString() // read string
  1074. }
  1075. nn := oo
  1076. v = nn
  1077. var z string
  1078. var rr string
  1079. if ctx.IsStringTable() {
  1080. ss := buff.ReadInt() // read string index
  1081. rr = ctx.Table[ss]
  1082. } else {
  1083. rr = buff.ReadString() // read string
  1084. }
  1085. qq := rr
  1086. z = qq
  1087. ll[v] = z
  1088. }
  1089. kk = ll
  1090. // --- [end][read][map](map[string]string) ---
  1091. }
  1092. target.Labels = AllocationLabels(kk)
  1093. // --- [end][read][alias](AllocationLabels) ---
  1094. // --- [begin][read][alias](AllocationAnnotations) ---
  1095. var tt map[string]string
  1096. if buff.ReadUInt8() == uint8(0) {
  1097. tt = nil
  1098. } else {
  1099. // --- [begin][read][map](map[string]string) ---
  1100. ww := buff.ReadInt() // map len
  1101. uu := make(map[string]string, ww)
  1102. for ii := 0; ii < ww; ii++ {
  1103. var vv string
  1104. var yy string
  1105. if ctx.IsStringTable() {
  1106. aaa := buff.ReadInt() // read string index
  1107. yy = ctx.Table[aaa]
  1108. } else {
  1109. yy = buff.ReadString() // read string
  1110. }
  1111. xx := yy
  1112. vv = xx
  1113. var zz string
  1114. var ccc string
  1115. if ctx.IsStringTable() {
  1116. ddd := buff.ReadInt() // read string index
  1117. ccc = ctx.Table[ddd]
  1118. } else {
  1119. ccc = buff.ReadString() // read string
  1120. }
  1121. bbb := ccc
  1122. zz = bbb
  1123. uu[vv] = zz
  1124. }
  1125. tt = uu
  1126. // --- [end][read][map](map[string]string) ---
  1127. }
  1128. target.Annotations = AllocationAnnotations(tt)
  1129. // --- [end][read][alias](AllocationAnnotations) ---
  1130. // field version check
  1131. if uint8(17) <= version {
  1132. // --- [begin][read][alias](AllocationLabels) ---
  1133. var eee map[string]string
  1134. if buff.ReadUInt8() == uint8(0) {
  1135. eee = nil
  1136. } else {
  1137. // --- [begin][read][map](map[string]string) ---
  1138. ggg := buff.ReadInt() // map len
  1139. fff := make(map[string]string, ggg)
  1140. for jj := 0; jj < ggg; jj++ {
  1141. var vvv string
  1142. var kkk string
  1143. if ctx.IsStringTable() {
  1144. lll := buff.ReadInt() // read string index
  1145. kkk = ctx.Table[lll]
  1146. } else {
  1147. kkk = buff.ReadString() // read string
  1148. }
  1149. hhh := kkk
  1150. vvv = hhh
  1151. var zzz string
  1152. var nnn string
  1153. if ctx.IsStringTable() {
  1154. ooo := buff.ReadInt() // read string index
  1155. nnn = ctx.Table[ooo]
  1156. } else {
  1157. nnn = buff.ReadString() // read string
  1158. }
  1159. mmm := nnn
  1160. zzz = mmm
  1161. fff[vvv] = zzz
  1162. }
  1163. eee = fff
  1164. // --- [end][read][map](map[string]string) ---
  1165. }
  1166. target.NamespaceLabels = AllocationLabels(eee)
  1167. // --- [end][read][alias](AllocationLabels) ---
  1168. } else {
  1169. }
  1170. // field version check
  1171. if uint8(17) <= version {
  1172. // --- [begin][read][alias](AllocationAnnotations) ---
  1173. var ppp map[string]string
  1174. if buff.ReadUInt8() == uint8(0) {
  1175. ppp = nil
  1176. } else {
  1177. // --- [begin][read][map](map[string]string) ---
  1178. rrr := buff.ReadInt() // map len
  1179. qqq := make(map[string]string, rrr)
  1180. for iii := 0; iii < rrr; iii++ {
  1181. var vvvv string
  1182. var ttt string
  1183. if ctx.IsStringTable() {
  1184. uuu := buff.ReadInt() // read string index
  1185. ttt = ctx.Table[uuu]
  1186. } else {
  1187. ttt = buff.ReadString() // read string
  1188. }
  1189. sss := ttt
  1190. vvvv = sss
  1191. var zzzz string
  1192. var xxx string
  1193. if ctx.IsStringTable() {
  1194. yyy := buff.ReadInt() // read string index
  1195. xxx = ctx.Table[yyy]
  1196. } else {
  1197. xxx = buff.ReadString() // read string
  1198. }
  1199. www := xxx
  1200. zzzz = www
  1201. qqq[vvvv] = zzzz
  1202. }
  1203. ppp = qqq
  1204. // --- [end][read][map](map[string]string) ---
  1205. }
  1206. target.NamespaceAnnotations = AllocationAnnotations(ppp)
  1207. // --- [end][read][alias](AllocationAnnotations) ---
  1208. } else {
  1209. }
  1210. return nil
  1211. }
  1212. //--------------------------------------------------------------------------
  1213. // AllocationSet
  1214. //--------------------------------------------------------------------------
  1215. // MarshalBinary serializes the internal properties of this AllocationSet instance
  1216. // into a byte array
  1217. func (target *AllocationSet) MarshalBinary() (data []byte, err error) {
  1218. ctx := &EncodingContext{
  1219. Buffer: util.NewBuffer(),
  1220. Table: NewStringTable(),
  1221. }
  1222. e := target.MarshalBinaryWithContext(ctx)
  1223. if e != nil {
  1224. return nil, e
  1225. }
  1226. encBytes := ctx.Buffer.Bytes()
  1227. sTableBytes := ctx.Table.ToBytes()
  1228. merged := appendBytes(sTableBytes, encBytes)
  1229. return merged, nil
  1230. }
  1231. // MarshalBinaryWithContext serializes the internal properties of this AllocationSet instance
  1232. // into a byte array leveraging a predefined context.
  1233. func (target *AllocationSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  1234. // panics are recovered and propagated as errors
  1235. defer func() {
  1236. if r := recover(); r != nil {
  1237. if e, ok := r.(error); ok {
  1238. err = e
  1239. } else if s, ok := r.(string); ok {
  1240. err = fmt.Errorf("Unexpected panic: %s", s)
  1241. } else {
  1242. err = fmt.Errorf("Unexpected panic: %+v", r)
  1243. }
  1244. }
  1245. }()
  1246. buff := ctx.Buffer
  1247. buff.WriteUInt8(AllocationCodecVersion) // version
  1248. if target.Allocations == nil {
  1249. buff.WriteUInt8(uint8(0)) // write nil byte
  1250. } else {
  1251. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1252. // --- [begin][write][map](map[string]*Allocation) ---
  1253. buff.WriteInt(len(target.Allocations)) // map length
  1254. for v, z := range target.Allocations {
  1255. if ctx.IsStringTable() {
  1256. a := ctx.Table.AddOrGet(v)
  1257. buff.WriteInt(a) // write table index
  1258. } else {
  1259. buff.WriteString(v) // write string
  1260. }
  1261. if z == nil {
  1262. buff.WriteUInt8(uint8(0)) // write nil byte
  1263. } else {
  1264. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1265. // --- [begin][write][struct](Allocation) ---
  1266. buff.WriteInt(0) // [compatibility, unused]
  1267. errA := z.MarshalBinaryWithContext(ctx)
  1268. if errA != nil {
  1269. return errA
  1270. }
  1271. // --- [end][write][struct](Allocation) ---
  1272. }
  1273. }
  1274. // --- [end][write][map](map[string]*Allocation) ---
  1275. }
  1276. if target.ExternalKeys == nil {
  1277. buff.WriteUInt8(uint8(0)) // write nil byte
  1278. } else {
  1279. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1280. // --- [begin][write][map](map[string]bool) ---
  1281. buff.WriteInt(len(target.ExternalKeys)) // map length
  1282. for vv, zz := range target.ExternalKeys {
  1283. if ctx.IsStringTable() {
  1284. b := ctx.Table.AddOrGet(vv)
  1285. buff.WriteInt(b) // write table index
  1286. } else {
  1287. buff.WriteString(vv) // write string
  1288. }
  1289. buff.WriteBool(zz) // write bool
  1290. }
  1291. // --- [end][write][map](map[string]bool) ---
  1292. }
  1293. if target.IdleKeys == nil {
  1294. buff.WriteUInt8(uint8(0)) // write nil byte
  1295. } else {
  1296. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1297. // --- [begin][write][map](map[string]bool) ---
  1298. buff.WriteInt(len(target.IdleKeys)) // map length
  1299. for vvv, zzz := range target.IdleKeys {
  1300. if ctx.IsStringTable() {
  1301. c := ctx.Table.AddOrGet(vvv)
  1302. buff.WriteInt(c) // write table index
  1303. } else {
  1304. buff.WriteString(vvv) // write string
  1305. }
  1306. buff.WriteBool(zzz) // write bool
  1307. }
  1308. // --- [end][write][map](map[string]bool) ---
  1309. }
  1310. if ctx.IsStringTable() {
  1311. d := ctx.Table.AddOrGet(target.FromSource)
  1312. buff.WriteInt(d) // write table index
  1313. } else {
  1314. buff.WriteString(target.FromSource) // write string
  1315. }
  1316. // --- [begin][write][struct](Window) ---
  1317. buff.WriteInt(0) // [compatibility, unused]
  1318. errB := target.Window.MarshalBinaryWithContext(ctx)
  1319. if errB != nil {
  1320. return errB
  1321. }
  1322. // --- [end][write][struct](Window) ---
  1323. if target.Warnings == nil {
  1324. buff.WriteUInt8(uint8(0)) // write nil byte
  1325. } else {
  1326. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1327. // --- [begin][write][slice]([]string) ---
  1328. buff.WriteInt(len(target.Warnings)) // array length
  1329. for i := 0; i < len(target.Warnings); i++ {
  1330. if ctx.IsStringTable() {
  1331. e := ctx.Table.AddOrGet(target.Warnings[i])
  1332. buff.WriteInt(e) // write table index
  1333. } else {
  1334. buff.WriteString(target.Warnings[i]) // write string
  1335. }
  1336. }
  1337. // --- [end][write][slice]([]string) ---
  1338. }
  1339. if target.Errors == nil {
  1340. buff.WriteUInt8(uint8(0)) // write nil byte
  1341. } else {
  1342. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1343. // --- [begin][write][slice]([]string) ---
  1344. buff.WriteInt(len(target.Errors)) // array length
  1345. for j := 0; j < len(target.Errors); j++ {
  1346. if ctx.IsStringTable() {
  1347. f := ctx.Table.AddOrGet(target.Errors[j])
  1348. buff.WriteInt(f) // write table index
  1349. } else {
  1350. buff.WriteString(target.Errors[j]) // write string
  1351. }
  1352. }
  1353. // --- [end][write][slice]([]string) ---
  1354. }
  1355. return nil
  1356. }
  1357. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1358. // the AllocationSet type
  1359. func (target *AllocationSet) UnmarshalBinary(data []byte) error {
  1360. var table []string
  1361. buff := util.NewBufferFromBytes(data)
  1362. // string table header validation
  1363. if isBinaryTag(data, BinaryTagStringTable) {
  1364. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  1365. tl := buff.ReadInt() // table length
  1366. if tl > 0 {
  1367. table = make([]string, tl, tl)
  1368. for i := 0; i < tl; i++ {
  1369. table[i] = buff.ReadString()
  1370. }
  1371. }
  1372. }
  1373. ctx := &DecodingContext{
  1374. Buffer: buff,
  1375. Table: table,
  1376. }
  1377. err := target.UnmarshalBinaryWithContext(ctx)
  1378. if err != nil {
  1379. return err
  1380. }
  1381. return nil
  1382. }
  1383. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  1384. // the AllocationSet type
  1385. func (target *AllocationSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  1386. // panics are recovered and propagated as errors
  1387. defer func() {
  1388. if r := recover(); r != nil {
  1389. if e, ok := r.(error); ok {
  1390. err = e
  1391. } else if s, ok := r.(string); ok {
  1392. err = fmt.Errorf("Unexpected panic: %s", s)
  1393. } else {
  1394. err = fmt.Errorf("Unexpected panic: %+v", r)
  1395. }
  1396. }
  1397. }()
  1398. buff := ctx.Buffer
  1399. version := buff.ReadUInt8()
  1400. if version > AllocationCodecVersion {
  1401. return fmt.Errorf("Invalid Version Unmarshaling AllocationSet. Expected %d or less, got %d", AllocationCodecVersion, version)
  1402. }
  1403. if buff.ReadUInt8() == uint8(0) {
  1404. target.Allocations = nil
  1405. } else {
  1406. // --- [begin][read][map](map[string]*Allocation) ---
  1407. b := buff.ReadInt() // map len
  1408. a := make(map[string]*Allocation, b)
  1409. for i := 0; i < b; i++ {
  1410. var v string
  1411. var d string
  1412. if ctx.IsStringTable() {
  1413. e := buff.ReadInt() // read string index
  1414. d = ctx.Table[e]
  1415. } else {
  1416. d = buff.ReadString() // read string
  1417. }
  1418. c := d
  1419. v = c
  1420. var z *Allocation
  1421. if buff.ReadUInt8() == uint8(0) {
  1422. z = nil
  1423. } else {
  1424. // --- [begin][read][struct](Allocation) ---
  1425. f := &Allocation{}
  1426. buff.ReadInt() // [compatibility, unused]
  1427. errA := f.UnmarshalBinaryWithContext(ctx)
  1428. if errA != nil {
  1429. return errA
  1430. }
  1431. z = f
  1432. // --- [end][read][struct](Allocation) ---
  1433. }
  1434. a[v] = z
  1435. }
  1436. target.Allocations = a
  1437. // --- [end][read][map](map[string]*Allocation) ---
  1438. }
  1439. if buff.ReadUInt8() == uint8(0) {
  1440. target.ExternalKeys = nil
  1441. } else {
  1442. // --- [begin][read][map](map[string]bool) ---
  1443. h := buff.ReadInt() // map len
  1444. g := make(map[string]bool, h)
  1445. for j := 0; j < h; j++ {
  1446. var vv string
  1447. var l string
  1448. if ctx.IsStringTable() {
  1449. m := buff.ReadInt() // read string index
  1450. l = ctx.Table[m]
  1451. } else {
  1452. l = buff.ReadString() // read string
  1453. }
  1454. k := l
  1455. vv = k
  1456. var zz bool
  1457. n := buff.ReadBool() // read bool
  1458. zz = n
  1459. g[vv] = zz
  1460. }
  1461. target.ExternalKeys = g
  1462. // --- [end][read][map](map[string]bool) ---
  1463. }
  1464. if buff.ReadUInt8() == uint8(0) {
  1465. target.IdleKeys = nil
  1466. } else {
  1467. // --- [begin][read][map](map[string]bool) ---
  1468. p := buff.ReadInt() // map len
  1469. o := make(map[string]bool, p)
  1470. for ii := 0; ii < p; ii++ {
  1471. var vvv string
  1472. var r string
  1473. if ctx.IsStringTable() {
  1474. s := buff.ReadInt() // read string index
  1475. r = ctx.Table[s]
  1476. } else {
  1477. r = buff.ReadString() // read string
  1478. }
  1479. q := r
  1480. vvv = q
  1481. var zzz bool
  1482. t := buff.ReadBool() // read bool
  1483. zzz = t
  1484. o[vvv] = zzz
  1485. }
  1486. target.IdleKeys = o
  1487. // --- [end][read][map](map[string]bool) ---
  1488. }
  1489. var w string
  1490. if ctx.IsStringTable() {
  1491. x := buff.ReadInt() // read string index
  1492. w = ctx.Table[x]
  1493. } else {
  1494. w = buff.ReadString() // read string
  1495. }
  1496. u := w
  1497. target.FromSource = u
  1498. // --- [begin][read][struct](Window) ---
  1499. y := &Window{}
  1500. buff.ReadInt() // [compatibility, unused]
  1501. errB := y.UnmarshalBinaryWithContext(ctx)
  1502. if errB != nil {
  1503. return errB
  1504. }
  1505. target.Window = *y
  1506. // --- [end][read][struct](Window) ---
  1507. if buff.ReadUInt8() == uint8(0) {
  1508. target.Warnings = nil
  1509. } else {
  1510. // --- [begin][read][slice]([]string) ---
  1511. bb := buff.ReadInt() // array len
  1512. aa := make([]string, bb)
  1513. for jj := 0; jj < bb; jj++ {
  1514. var cc string
  1515. var ee string
  1516. if ctx.IsStringTable() {
  1517. ff := buff.ReadInt() // read string index
  1518. ee = ctx.Table[ff]
  1519. } else {
  1520. ee = buff.ReadString() // read string
  1521. }
  1522. dd := ee
  1523. cc = dd
  1524. aa[jj] = cc
  1525. }
  1526. target.Warnings = aa
  1527. // --- [end][read][slice]([]string) ---
  1528. }
  1529. if buff.ReadUInt8() == uint8(0) {
  1530. target.Errors = nil
  1531. } else {
  1532. // --- [begin][read][slice]([]string) ---
  1533. hh := buff.ReadInt() // array len
  1534. gg := make([]string, hh)
  1535. for iii := 0; iii < hh; iii++ {
  1536. var kk string
  1537. var mm string
  1538. if ctx.IsStringTable() {
  1539. nn := buff.ReadInt() // read string index
  1540. mm = ctx.Table[nn]
  1541. } else {
  1542. mm = buff.ReadString() // read string
  1543. }
  1544. ll := mm
  1545. kk = ll
  1546. gg[iii] = kk
  1547. }
  1548. target.Errors = gg
  1549. // --- [end][read][slice]([]string) ---
  1550. }
  1551. return nil
  1552. }
  1553. //--------------------------------------------------------------------------
  1554. // AllocationSetRange
  1555. //--------------------------------------------------------------------------
  1556. // MarshalBinary serializes the internal properties of this AllocationSetRange instance
  1557. // into a byte array
  1558. func (target *AllocationSetRange) MarshalBinary() (data []byte, err error) {
  1559. ctx := &EncodingContext{
  1560. Buffer: util.NewBuffer(),
  1561. Table: nil,
  1562. }
  1563. e := target.MarshalBinaryWithContext(ctx)
  1564. if e != nil {
  1565. return nil, e
  1566. }
  1567. encBytes := ctx.Buffer.Bytes()
  1568. return encBytes, nil
  1569. }
  1570. // MarshalBinaryWithContext serializes the internal properties of this AllocationSetRange instance
  1571. // into a byte array leveraging a predefined context.
  1572. func (target *AllocationSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  1573. // panics are recovered and propagated as errors
  1574. defer func() {
  1575. if r := recover(); r != nil {
  1576. if e, ok := r.(error); ok {
  1577. err = e
  1578. } else if s, ok := r.(string); ok {
  1579. err = fmt.Errorf("Unexpected panic: %s", s)
  1580. } else {
  1581. err = fmt.Errorf("Unexpected panic: %+v", r)
  1582. }
  1583. }
  1584. }()
  1585. buff := ctx.Buffer
  1586. buff.WriteUInt8(AllocationCodecVersion) // version
  1587. if target.Allocations == nil {
  1588. buff.WriteUInt8(uint8(0)) // write nil byte
  1589. } else {
  1590. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1591. // --- [begin][write][slice]([]*AllocationSet) ---
  1592. buff.WriteInt(len(target.Allocations)) // array length
  1593. for i := 0; i < len(target.Allocations); i++ {
  1594. if target.Allocations[i] == nil {
  1595. buff.WriteUInt8(uint8(0)) // write nil byte
  1596. } else {
  1597. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1598. // --- [begin][write][struct](AllocationSet) ---
  1599. buff.WriteInt(0) // [compatibility, unused]
  1600. errA := target.Allocations[i].MarshalBinaryWithContext(ctx)
  1601. if errA != nil {
  1602. return errA
  1603. }
  1604. // --- [end][write][struct](AllocationSet) ---
  1605. }
  1606. }
  1607. // --- [end][write][slice]([]*AllocationSet) ---
  1608. }
  1609. if ctx.IsStringTable() {
  1610. a := ctx.Table.AddOrGet(target.FromStore)
  1611. buff.WriteInt(a) // write table index
  1612. } else {
  1613. buff.WriteString(target.FromStore) // write string
  1614. }
  1615. return nil
  1616. }
  1617. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1618. // the AllocationSetRange type
  1619. func (target *AllocationSetRange) UnmarshalBinary(data []byte) error {
  1620. var table []string
  1621. buff := util.NewBufferFromBytes(data)
  1622. // string table header validation
  1623. if isBinaryTag(data, BinaryTagStringTable) {
  1624. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  1625. tl := buff.ReadInt() // table length
  1626. if tl > 0 {
  1627. table = make([]string, tl, tl)
  1628. for i := 0; i < tl; i++ {
  1629. table[i] = buff.ReadString()
  1630. }
  1631. }
  1632. }
  1633. ctx := &DecodingContext{
  1634. Buffer: buff,
  1635. Table: table,
  1636. }
  1637. err := target.UnmarshalBinaryWithContext(ctx)
  1638. if err != nil {
  1639. return err
  1640. }
  1641. return nil
  1642. }
  1643. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  1644. // the AllocationSetRange type
  1645. func (target *AllocationSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  1646. // panics are recovered and propagated as errors
  1647. defer func() {
  1648. if r := recover(); r != nil {
  1649. if e, ok := r.(error); ok {
  1650. err = e
  1651. } else if s, ok := r.(string); ok {
  1652. err = fmt.Errorf("Unexpected panic: %s", s)
  1653. } else {
  1654. err = fmt.Errorf("Unexpected panic: %+v", r)
  1655. }
  1656. }
  1657. }()
  1658. buff := ctx.Buffer
  1659. version := buff.ReadUInt8()
  1660. if version > AllocationCodecVersion {
  1661. return fmt.Errorf("Invalid Version Unmarshaling AllocationSetRange. Expected %d or less, got %d", AllocationCodecVersion, version)
  1662. }
  1663. if buff.ReadUInt8() == uint8(0) {
  1664. target.Allocations = nil
  1665. } else {
  1666. // --- [begin][read][slice]([]*AllocationSet) ---
  1667. b := buff.ReadInt() // array len
  1668. a := make([]*AllocationSet, b)
  1669. for i := 0; i < b; i++ {
  1670. var c *AllocationSet
  1671. if buff.ReadUInt8() == uint8(0) {
  1672. c = nil
  1673. } else {
  1674. // --- [begin][read][struct](AllocationSet) ---
  1675. d := &AllocationSet{}
  1676. buff.ReadInt() // [compatibility, unused]
  1677. errA := d.UnmarshalBinaryWithContext(ctx)
  1678. if errA != nil {
  1679. return errA
  1680. }
  1681. c = d
  1682. // --- [end][read][struct](AllocationSet) ---
  1683. }
  1684. a[i] = c
  1685. }
  1686. target.Allocations = a
  1687. // --- [end][read][slice]([]*AllocationSet) ---
  1688. }
  1689. var f string
  1690. if ctx.IsStringTable() {
  1691. g := buff.ReadInt() // read string index
  1692. f = ctx.Table[g]
  1693. } else {
  1694. f = buff.ReadString() // read string
  1695. }
  1696. e := f
  1697. target.FromStore = e
  1698. return nil
  1699. }
  1700. //--------------------------------------------------------------------------
  1701. // Any
  1702. //--------------------------------------------------------------------------
  1703. // MarshalBinary serializes the internal properties of this Any instance
  1704. // into a byte array
  1705. func (target *Any) MarshalBinary() (data []byte, err error) {
  1706. ctx := &EncodingContext{
  1707. Buffer: util.NewBuffer(),
  1708. Table: nil,
  1709. }
  1710. e := target.MarshalBinaryWithContext(ctx)
  1711. if e != nil {
  1712. return nil, e
  1713. }
  1714. encBytes := ctx.Buffer.Bytes()
  1715. return encBytes, nil
  1716. }
  1717. // MarshalBinaryWithContext serializes the internal properties of this Any instance
  1718. // into a byte array leveraging a predefined context.
  1719. func (target *Any) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  1720. // panics are recovered and propagated as errors
  1721. defer func() {
  1722. if r := recover(); r != nil {
  1723. if e, ok := r.(error); ok {
  1724. err = e
  1725. } else if s, ok := r.(string); ok {
  1726. err = fmt.Errorf("Unexpected panic: %s", s)
  1727. } else {
  1728. err = fmt.Errorf("Unexpected panic: %+v", r)
  1729. }
  1730. }
  1731. }()
  1732. buff := ctx.Buffer
  1733. buff.WriteUInt8(AssetsCodecVersion) // version
  1734. // --- [begin][write][alias](AssetLabels) ---
  1735. if map[string]string(target.Labels) == nil {
  1736. buff.WriteUInt8(uint8(0)) // write nil byte
  1737. } else {
  1738. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1739. // --- [begin][write][map](map[string]string) ---
  1740. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  1741. for v, z := range map[string]string(target.Labels) {
  1742. if ctx.IsStringTable() {
  1743. a := ctx.Table.AddOrGet(v)
  1744. buff.WriteInt(a) // write table index
  1745. } else {
  1746. buff.WriteString(v) // write string
  1747. }
  1748. if ctx.IsStringTable() {
  1749. b := ctx.Table.AddOrGet(z)
  1750. buff.WriteInt(b) // write table index
  1751. } else {
  1752. buff.WriteString(z) // write string
  1753. }
  1754. }
  1755. // --- [end][write][map](map[string]string) ---
  1756. }
  1757. // --- [end][write][alias](AssetLabels) ---
  1758. if target.Properties == nil {
  1759. buff.WriteUInt8(uint8(0)) // write nil byte
  1760. } else {
  1761. buff.WriteUInt8(uint8(1)) // write non-nil byte
  1762. // --- [begin][write][struct](AssetProperties) ---
  1763. buff.WriteInt(0) // [compatibility, unused]
  1764. errA := target.Properties.MarshalBinaryWithContext(ctx)
  1765. if errA != nil {
  1766. return errA
  1767. }
  1768. // --- [end][write][struct](AssetProperties) ---
  1769. }
  1770. // --- [begin][write][reference](time.Time) ---
  1771. c, errB := target.Start.MarshalBinary()
  1772. if errB != nil {
  1773. return errB
  1774. }
  1775. buff.WriteInt(len(c))
  1776. buff.WriteBytes(c)
  1777. // --- [end][write][reference](time.Time) ---
  1778. // --- [begin][write][reference](time.Time) ---
  1779. d, errC := target.End.MarshalBinary()
  1780. if errC != nil {
  1781. return errC
  1782. }
  1783. buff.WriteInt(len(d))
  1784. buff.WriteBytes(d)
  1785. // --- [end][write][reference](time.Time) ---
  1786. // --- [begin][write][struct](Window) ---
  1787. buff.WriteInt(0) // [compatibility, unused]
  1788. errD := target.Window.MarshalBinaryWithContext(ctx)
  1789. if errD != nil {
  1790. return errD
  1791. }
  1792. // --- [end][write][struct](Window) ---
  1793. buff.WriteFloat64(target.Adjustment) // write float64
  1794. buff.WriteFloat64(target.Cost) // write float64
  1795. return nil
  1796. }
  1797. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  1798. // the Any type
  1799. func (target *Any) UnmarshalBinary(data []byte) error {
  1800. var table []string
  1801. buff := util.NewBufferFromBytes(data)
  1802. // string table header validation
  1803. if isBinaryTag(data, BinaryTagStringTable) {
  1804. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  1805. tl := buff.ReadInt() // table length
  1806. if tl > 0 {
  1807. table = make([]string, tl, tl)
  1808. for i := 0; i < tl; i++ {
  1809. table[i] = buff.ReadString()
  1810. }
  1811. }
  1812. }
  1813. ctx := &DecodingContext{
  1814. Buffer: buff,
  1815. Table: table,
  1816. }
  1817. err := target.UnmarshalBinaryWithContext(ctx)
  1818. if err != nil {
  1819. return err
  1820. }
  1821. return nil
  1822. }
  1823. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  1824. // the Any type
  1825. func (target *Any) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  1826. // panics are recovered and propagated as errors
  1827. defer func() {
  1828. if r := recover(); r != nil {
  1829. if e, ok := r.(error); ok {
  1830. err = e
  1831. } else if s, ok := r.(string); ok {
  1832. err = fmt.Errorf("Unexpected panic: %s", s)
  1833. } else {
  1834. err = fmt.Errorf("Unexpected panic: %+v", r)
  1835. }
  1836. }
  1837. }()
  1838. buff := ctx.Buffer
  1839. version := buff.ReadUInt8()
  1840. if version > AssetsCodecVersion {
  1841. return fmt.Errorf("Invalid Version Unmarshaling Any. Expected %d or less, got %d", AssetsCodecVersion, version)
  1842. }
  1843. // --- [begin][read][alias](AssetLabels) ---
  1844. var a map[string]string
  1845. if buff.ReadUInt8() == uint8(0) {
  1846. a = nil
  1847. } else {
  1848. // --- [begin][read][map](map[string]string) ---
  1849. c := buff.ReadInt() // map len
  1850. b := make(map[string]string, c)
  1851. for i := 0; i < c; i++ {
  1852. var v string
  1853. var e string
  1854. if ctx.IsStringTable() {
  1855. f := buff.ReadInt() // read string index
  1856. e = ctx.Table[f]
  1857. } else {
  1858. e = buff.ReadString() // read string
  1859. }
  1860. d := e
  1861. v = d
  1862. var z string
  1863. var h string
  1864. if ctx.IsStringTable() {
  1865. k := buff.ReadInt() // read string index
  1866. h = ctx.Table[k]
  1867. } else {
  1868. h = buff.ReadString() // read string
  1869. }
  1870. g := h
  1871. z = g
  1872. b[v] = z
  1873. }
  1874. a = b
  1875. // --- [end][read][map](map[string]string) ---
  1876. }
  1877. target.Labels = AssetLabels(a)
  1878. // --- [end][read][alias](AssetLabels) ---
  1879. if buff.ReadUInt8() == uint8(0) {
  1880. target.Properties = nil
  1881. } else {
  1882. // --- [begin][read][struct](AssetProperties) ---
  1883. l := &AssetProperties{}
  1884. buff.ReadInt() // [compatibility, unused]
  1885. errA := l.UnmarshalBinaryWithContext(ctx)
  1886. if errA != nil {
  1887. return errA
  1888. }
  1889. target.Properties = l
  1890. // --- [end][read][struct](AssetProperties) ---
  1891. }
  1892. // --- [begin][read][reference](time.Time) ---
  1893. m := &time.Time{}
  1894. n := buff.ReadInt() // byte array length
  1895. o := buff.ReadBytes(n) // byte array
  1896. errB := m.UnmarshalBinary(o)
  1897. if errB != nil {
  1898. return errB
  1899. }
  1900. target.Start = *m
  1901. // --- [end][read][reference](time.Time) ---
  1902. // --- [begin][read][reference](time.Time) ---
  1903. p := &time.Time{}
  1904. q := buff.ReadInt() // byte array length
  1905. r := buff.ReadBytes(q) // byte array
  1906. errC := p.UnmarshalBinary(r)
  1907. if errC != nil {
  1908. return errC
  1909. }
  1910. target.End = *p
  1911. // --- [end][read][reference](time.Time) ---
  1912. // --- [begin][read][struct](Window) ---
  1913. s := &Window{}
  1914. buff.ReadInt() // [compatibility, unused]
  1915. errD := s.UnmarshalBinaryWithContext(ctx)
  1916. if errD != nil {
  1917. return errD
  1918. }
  1919. target.Window = *s
  1920. // --- [end][read][struct](Window) ---
  1921. t := buff.ReadFloat64() // read float64
  1922. target.Adjustment = t
  1923. u := buff.ReadFloat64() // read float64
  1924. target.Cost = u
  1925. return nil
  1926. }
  1927. //--------------------------------------------------------------------------
  1928. // AssetProperties
  1929. //--------------------------------------------------------------------------
  1930. // MarshalBinary serializes the internal properties of this AssetProperties instance
  1931. // into a byte array
  1932. func (target *AssetProperties) MarshalBinary() (data []byte, err error) {
  1933. ctx := &EncodingContext{
  1934. Buffer: util.NewBuffer(),
  1935. Table: nil,
  1936. }
  1937. e := target.MarshalBinaryWithContext(ctx)
  1938. if e != nil {
  1939. return nil, e
  1940. }
  1941. encBytes := ctx.Buffer.Bytes()
  1942. return encBytes, nil
  1943. }
  1944. // MarshalBinaryWithContext serializes the internal properties of this AssetProperties instance
  1945. // into a byte array leveraging a predefined context.
  1946. func (target *AssetProperties) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  1947. // panics are recovered and propagated as errors
  1948. defer func() {
  1949. if r := recover(); r != nil {
  1950. if e, ok := r.(error); ok {
  1951. err = e
  1952. } else if s, ok := r.(string); ok {
  1953. err = fmt.Errorf("Unexpected panic: %s", s)
  1954. } else {
  1955. err = fmt.Errorf("Unexpected panic: %+v", r)
  1956. }
  1957. }
  1958. }()
  1959. buff := ctx.Buffer
  1960. buff.WriteUInt8(AssetsCodecVersion) // version
  1961. if ctx.IsStringTable() {
  1962. a := ctx.Table.AddOrGet(target.Category)
  1963. buff.WriteInt(a) // write table index
  1964. } else {
  1965. buff.WriteString(target.Category) // write string
  1966. }
  1967. if ctx.IsStringTable() {
  1968. b := ctx.Table.AddOrGet(target.Provider)
  1969. buff.WriteInt(b) // write table index
  1970. } else {
  1971. buff.WriteString(target.Provider) // write string
  1972. }
  1973. if ctx.IsStringTable() {
  1974. c := ctx.Table.AddOrGet(target.Account)
  1975. buff.WriteInt(c) // write table index
  1976. } else {
  1977. buff.WriteString(target.Account) // write string
  1978. }
  1979. if ctx.IsStringTable() {
  1980. d := ctx.Table.AddOrGet(target.Project)
  1981. buff.WriteInt(d) // write table index
  1982. } else {
  1983. buff.WriteString(target.Project) // write string
  1984. }
  1985. if ctx.IsStringTable() {
  1986. e := ctx.Table.AddOrGet(target.Service)
  1987. buff.WriteInt(e) // write table index
  1988. } else {
  1989. buff.WriteString(target.Service) // write string
  1990. }
  1991. if ctx.IsStringTable() {
  1992. f := ctx.Table.AddOrGet(target.Cluster)
  1993. buff.WriteInt(f) // write table index
  1994. } else {
  1995. buff.WriteString(target.Cluster) // write string
  1996. }
  1997. if ctx.IsStringTable() {
  1998. g := ctx.Table.AddOrGet(target.Name)
  1999. buff.WriteInt(g) // write table index
  2000. } else {
  2001. buff.WriteString(target.Name) // write string
  2002. }
  2003. if ctx.IsStringTable() {
  2004. h := ctx.Table.AddOrGet(target.ProviderID)
  2005. buff.WriteInt(h) // write table index
  2006. } else {
  2007. buff.WriteString(target.ProviderID) // write string
  2008. }
  2009. return nil
  2010. }
  2011. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2012. // the AssetProperties type
  2013. func (target *AssetProperties) UnmarshalBinary(data []byte) error {
  2014. var table []string
  2015. buff := util.NewBufferFromBytes(data)
  2016. // string table header validation
  2017. if isBinaryTag(data, BinaryTagStringTable) {
  2018. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  2019. tl := buff.ReadInt() // table length
  2020. if tl > 0 {
  2021. table = make([]string, tl, tl)
  2022. for i := 0; i < tl; i++ {
  2023. table[i] = buff.ReadString()
  2024. }
  2025. }
  2026. }
  2027. ctx := &DecodingContext{
  2028. Buffer: buff,
  2029. Table: table,
  2030. }
  2031. err := target.UnmarshalBinaryWithContext(ctx)
  2032. if err != nil {
  2033. return err
  2034. }
  2035. return nil
  2036. }
  2037. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2038. // the AssetProperties type
  2039. func (target *AssetProperties) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2040. // panics are recovered and propagated as errors
  2041. defer func() {
  2042. if r := recover(); r != nil {
  2043. if e, ok := r.(error); ok {
  2044. err = e
  2045. } else if s, ok := r.(string); ok {
  2046. err = fmt.Errorf("Unexpected panic: %s", s)
  2047. } else {
  2048. err = fmt.Errorf("Unexpected panic: %+v", r)
  2049. }
  2050. }
  2051. }()
  2052. buff := ctx.Buffer
  2053. version := buff.ReadUInt8()
  2054. if version > AssetsCodecVersion {
  2055. return fmt.Errorf("Invalid Version Unmarshaling AssetProperties. Expected %d or less, got %d", AssetsCodecVersion, version)
  2056. }
  2057. var b string
  2058. if ctx.IsStringTable() {
  2059. c := buff.ReadInt() // read string index
  2060. b = ctx.Table[c]
  2061. } else {
  2062. b = buff.ReadString() // read string
  2063. }
  2064. a := b
  2065. target.Category = a
  2066. var e string
  2067. if ctx.IsStringTable() {
  2068. f := buff.ReadInt() // read string index
  2069. e = ctx.Table[f]
  2070. } else {
  2071. e = buff.ReadString() // read string
  2072. }
  2073. d := e
  2074. target.Provider = d
  2075. var h string
  2076. if ctx.IsStringTable() {
  2077. k := buff.ReadInt() // read string index
  2078. h = ctx.Table[k]
  2079. } else {
  2080. h = buff.ReadString() // read string
  2081. }
  2082. g := h
  2083. target.Account = g
  2084. var m string
  2085. if ctx.IsStringTable() {
  2086. n := buff.ReadInt() // read string index
  2087. m = ctx.Table[n]
  2088. } else {
  2089. m = buff.ReadString() // read string
  2090. }
  2091. l := m
  2092. target.Project = l
  2093. var p string
  2094. if ctx.IsStringTable() {
  2095. q := buff.ReadInt() // read string index
  2096. p = ctx.Table[q]
  2097. } else {
  2098. p = buff.ReadString() // read string
  2099. }
  2100. o := p
  2101. target.Service = o
  2102. var s string
  2103. if ctx.IsStringTable() {
  2104. t := buff.ReadInt() // read string index
  2105. s = ctx.Table[t]
  2106. } else {
  2107. s = buff.ReadString() // read string
  2108. }
  2109. r := s
  2110. target.Cluster = r
  2111. var w string
  2112. if ctx.IsStringTable() {
  2113. x := buff.ReadInt() // read string index
  2114. w = ctx.Table[x]
  2115. } else {
  2116. w = buff.ReadString() // read string
  2117. }
  2118. u := w
  2119. target.Name = u
  2120. var aa string
  2121. if ctx.IsStringTable() {
  2122. bb := buff.ReadInt() // read string index
  2123. aa = ctx.Table[bb]
  2124. } else {
  2125. aa = buff.ReadString() // read string
  2126. }
  2127. y := aa
  2128. target.ProviderID = y
  2129. return nil
  2130. }
  2131. //--------------------------------------------------------------------------
  2132. // AssetSet
  2133. //--------------------------------------------------------------------------
  2134. // MarshalBinary serializes the internal properties of this AssetSet instance
  2135. // into a byte array
  2136. func (target *AssetSet) MarshalBinary() (data []byte, err error) {
  2137. ctx := &EncodingContext{
  2138. Buffer: util.NewBuffer(),
  2139. Table: NewStringTable(),
  2140. }
  2141. e := target.MarshalBinaryWithContext(ctx)
  2142. if e != nil {
  2143. return nil, e
  2144. }
  2145. encBytes := ctx.Buffer.Bytes()
  2146. sTableBytes := ctx.Table.ToBytes()
  2147. merged := appendBytes(sTableBytes, encBytes)
  2148. return merged, nil
  2149. }
  2150. // MarshalBinaryWithContext serializes the internal properties of this AssetSet instance
  2151. // into a byte array leveraging a predefined context.
  2152. func (target *AssetSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2153. // panics are recovered and propagated as errors
  2154. defer func() {
  2155. if r := recover(); r != nil {
  2156. if e, ok := r.(error); ok {
  2157. err = e
  2158. } else if s, ok := r.(string); ok {
  2159. err = fmt.Errorf("Unexpected panic: %s", s)
  2160. } else {
  2161. err = fmt.Errorf("Unexpected panic: %+v", r)
  2162. }
  2163. }
  2164. }()
  2165. buff := ctx.Buffer
  2166. buff.WriteUInt8(AssetsCodecVersion) // version
  2167. // execute pre-processing func
  2168. preProcessAssetSet(target)
  2169. if target.AggregationKeys == nil {
  2170. buff.WriteUInt8(uint8(0)) // write nil byte
  2171. } else {
  2172. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2173. // --- [begin][write][slice]([]string) ---
  2174. buff.WriteInt(len(target.AggregationKeys)) // array length
  2175. for i := 0; i < len(target.AggregationKeys); i++ {
  2176. if ctx.IsStringTable() {
  2177. a := ctx.Table.AddOrGet(target.AggregationKeys[i])
  2178. buff.WriteInt(a) // write table index
  2179. } else {
  2180. buff.WriteString(target.AggregationKeys[i]) // write string
  2181. }
  2182. }
  2183. // --- [end][write][slice]([]string) ---
  2184. }
  2185. if target.Assets == nil {
  2186. buff.WriteUInt8(uint8(0)) // write nil byte
  2187. } else {
  2188. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2189. // --- [begin][write][map](map[string]Asset) ---
  2190. buff.WriteInt(len(target.Assets)) // map length
  2191. for v, z := range target.Assets {
  2192. if ctx.IsStringTable() {
  2193. b := ctx.Table.AddOrGet(v)
  2194. buff.WriteInt(b) // write table index
  2195. } else {
  2196. buff.WriteString(v) // write string
  2197. }
  2198. if z == nil {
  2199. buff.WriteUInt8(uint8(0)) // write nil byte
  2200. } else {
  2201. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2202. // --- [begin][write][interface](Asset) ---
  2203. c := reflect.ValueOf(z).Interface()
  2204. d, okA := c.(BinEncoder)
  2205. if !okA {
  2206. return fmt.Errorf("Type: %s does not implement %s.BinEncoder", typeToString(z), GeneratorPackageName)
  2207. }
  2208. buff.WriteString(typeToString(z))
  2209. buff.WriteInt(0) // [compatibility, unused]
  2210. errA := d.MarshalBinaryWithContext(ctx)
  2211. if errA != nil {
  2212. return errA
  2213. }
  2214. // --- [end][write][interface](Asset) ---
  2215. }
  2216. }
  2217. // --- [end][write][map](map[string]Asset) ---
  2218. }
  2219. if ctx.IsStringTable() {
  2220. e := ctx.Table.AddOrGet(target.FromSource)
  2221. buff.WriteInt(e) // write table index
  2222. } else {
  2223. buff.WriteString(target.FromSource) // write string
  2224. }
  2225. // --- [begin][write][struct](Window) ---
  2226. buff.WriteInt(0) // [compatibility, unused]
  2227. errB := target.Window.MarshalBinaryWithContext(ctx)
  2228. if errB != nil {
  2229. return errB
  2230. }
  2231. // --- [end][write][struct](Window) ---
  2232. if target.Warnings == nil {
  2233. buff.WriteUInt8(uint8(0)) // write nil byte
  2234. } else {
  2235. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2236. // --- [begin][write][slice]([]string) ---
  2237. buff.WriteInt(len(target.Warnings)) // array length
  2238. for j := 0; j < len(target.Warnings); j++ {
  2239. if ctx.IsStringTable() {
  2240. f := ctx.Table.AddOrGet(target.Warnings[j])
  2241. buff.WriteInt(f) // write table index
  2242. } else {
  2243. buff.WriteString(target.Warnings[j]) // write string
  2244. }
  2245. }
  2246. // --- [end][write][slice]([]string) ---
  2247. }
  2248. if target.Errors == nil {
  2249. buff.WriteUInt8(uint8(0)) // write nil byte
  2250. } else {
  2251. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2252. // --- [begin][write][slice]([]string) ---
  2253. buff.WriteInt(len(target.Errors)) // array length
  2254. for ii := 0; ii < len(target.Errors); ii++ {
  2255. if ctx.IsStringTable() {
  2256. g := ctx.Table.AddOrGet(target.Errors[ii])
  2257. buff.WriteInt(g) // write table index
  2258. } else {
  2259. buff.WriteString(target.Errors[ii]) // write string
  2260. }
  2261. }
  2262. // --- [end][write][slice]([]string) ---
  2263. }
  2264. return nil
  2265. }
  2266. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2267. // the AssetSet type
  2268. func (target *AssetSet) UnmarshalBinary(data []byte) error {
  2269. var table []string
  2270. buff := util.NewBufferFromBytes(data)
  2271. // string table header validation
  2272. if isBinaryTag(data, BinaryTagStringTable) {
  2273. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  2274. tl := buff.ReadInt() // table length
  2275. if tl > 0 {
  2276. table = make([]string, tl, tl)
  2277. for i := 0; i < tl; i++ {
  2278. table[i] = buff.ReadString()
  2279. }
  2280. }
  2281. }
  2282. ctx := &DecodingContext{
  2283. Buffer: buff,
  2284. Table: table,
  2285. }
  2286. err := target.UnmarshalBinaryWithContext(ctx)
  2287. if err != nil {
  2288. return err
  2289. }
  2290. return nil
  2291. }
  2292. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2293. // the AssetSet type
  2294. func (target *AssetSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2295. // panics are recovered and propagated as errors
  2296. defer func() {
  2297. if r := recover(); r != nil {
  2298. if e, ok := r.(error); ok {
  2299. err = e
  2300. } else if s, ok := r.(string); ok {
  2301. err = fmt.Errorf("Unexpected panic: %s", s)
  2302. } else {
  2303. err = fmt.Errorf("Unexpected panic: %+v", r)
  2304. }
  2305. }
  2306. }()
  2307. buff := ctx.Buffer
  2308. version := buff.ReadUInt8()
  2309. if version > AssetsCodecVersion {
  2310. return fmt.Errorf("Invalid Version Unmarshaling AssetSet. Expected %d or less, got %d", AssetsCodecVersion, version)
  2311. }
  2312. if buff.ReadUInt8() == uint8(0) {
  2313. target.AggregationKeys = nil
  2314. } else {
  2315. // --- [begin][read][slice]([]string) ---
  2316. b := buff.ReadInt() // array len
  2317. a := make([]string, b)
  2318. for i := 0; i < b; i++ {
  2319. var c string
  2320. var e string
  2321. if ctx.IsStringTable() {
  2322. f := buff.ReadInt() // read string index
  2323. e = ctx.Table[f]
  2324. } else {
  2325. e = buff.ReadString() // read string
  2326. }
  2327. d := e
  2328. c = d
  2329. a[i] = c
  2330. }
  2331. target.AggregationKeys = a
  2332. // --- [end][read][slice]([]string) ---
  2333. }
  2334. if buff.ReadUInt8() == uint8(0) {
  2335. target.Assets = nil
  2336. } else {
  2337. // --- [begin][read][map](map[string]Asset) ---
  2338. h := buff.ReadInt() // map len
  2339. g := make(map[string]Asset, h)
  2340. for j := 0; j < h; j++ {
  2341. var v string
  2342. var l string
  2343. if ctx.IsStringTable() {
  2344. m := buff.ReadInt() // read string index
  2345. l = ctx.Table[m]
  2346. } else {
  2347. l = buff.ReadString() // read string
  2348. }
  2349. k := l
  2350. v = k
  2351. var z Asset
  2352. if buff.ReadUInt8() == uint8(0) {
  2353. z = nil
  2354. } else {
  2355. // --- [begin][read][interface](Asset) ---
  2356. n := buff.ReadString()
  2357. _, o, _ := resolveType(n)
  2358. if _, ok := typeMap[o]; !ok {
  2359. return fmt.Errorf("Unknown Type: %s", o)
  2360. }
  2361. p, okA := reflect.New(typeMap[o]).Interface().(BinDecoder)
  2362. if !okA {
  2363. return fmt.Errorf("Type: %s does not implement %s.BinDecoder.", o, GeneratorPackageName)
  2364. }
  2365. buff.ReadInt() // [compatibility, unused]
  2366. errA := p.UnmarshalBinaryWithContext(ctx)
  2367. if errA != nil {
  2368. return errA
  2369. }
  2370. z = p.(Asset)
  2371. // --- [end][read][interface](Asset) ---
  2372. }
  2373. g[v] = z
  2374. }
  2375. target.Assets = g
  2376. // --- [end][read][map](map[string]Asset) ---
  2377. }
  2378. var r string
  2379. if ctx.IsStringTable() {
  2380. s := buff.ReadInt() // read string index
  2381. r = ctx.Table[s]
  2382. } else {
  2383. r = buff.ReadString() // read string
  2384. }
  2385. q := r
  2386. target.FromSource = q
  2387. // --- [begin][read][struct](Window) ---
  2388. t := &Window{}
  2389. buff.ReadInt() // [compatibility, unused]
  2390. errB := t.UnmarshalBinaryWithContext(ctx)
  2391. if errB != nil {
  2392. return errB
  2393. }
  2394. target.Window = *t
  2395. // --- [end][read][struct](Window) ---
  2396. if buff.ReadUInt8() == uint8(0) {
  2397. target.Warnings = nil
  2398. } else {
  2399. // --- [begin][read][slice]([]string) ---
  2400. w := buff.ReadInt() // array len
  2401. u := make([]string, w)
  2402. for ii := 0; ii < w; ii++ {
  2403. var x string
  2404. var aa string
  2405. if ctx.IsStringTable() {
  2406. bb := buff.ReadInt() // read string index
  2407. aa = ctx.Table[bb]
  2408. } else {
  2409. aa = buff.ReadString() // read string
  2410. }
  2411. y := aa
  2412. x = y
  2413. u[ii] = x
  2414. }
  2415. target.Warnings = u
  2416. // --- [end][read][slice]([]string) ---
  2417. }
  2418. if buff.ReadUInt8() == uint8(0) {
  2419. target.Errors = nil
  2420. } else {
  2421. // --- [begin][read][slice]([]string) ---
  2422. dd := buff.ReadInt() // array len
  2423. cc := make([]string, dd)
  2424. for jj := 0; jj < dd; jj++ {
  2425. var ee string
  2426. var gg string
  2427. if ctx.IsStringTable() {
  2428. hh := buff.ReadInt() // read string index
  2429. gg = ctx.Table[hh]
  2430. } else {
  2431. gg = buff.ReadString() // read string
  2432. }
  2433. ff := gg
  2434. ee = ff
  2435. cc[jj] = ee
  2436. }
  2437. target.Errors = cc
  2438. // --- [end][read][slice]([]string) ---
  2439. }
  2440. // execute post-processing func
  2441. postProcessAssetSet(target)
  2442. return nil
  2443. }
  2444. //--------------------------------------------------------------------------
  2445. // AssetSetRange
  2446. //--------------------------------------------------------------------------
  2447. // MarshalBinary serializes the internal properties of this AssetSetRange instance
  2448. // into a byte array
  2449. func (target *AssetSetRange) MarshalBinary() (data []byte, err error) {
  2450. ctx := &EncodingContext{
  2451. Buffer: util.NewBuffer(),
  2452. Table: nil,
  2453. }
  2454. e := target.MarshalBinaryWithContext(ctx)
  2455. if e != nil {
  2456. return nil, e
  2457. }
  2458. encBytes := ctx.Buffer.Bytes()
  2459. return encBytes, nil
  2460. }
  2461. // MarshalBinaryWithContext serializes the internal properties of this AssetSetRange instance
  2462. // into a byte array leveraging a predefined context.
  2463. func (target *AssetSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2464. // panics are recovered and propagated as errors
  2465. defer func() {
  2466. if r := recover(); r != nil {
  2467. if e, ok := r.(error); ok {
  2468. err = e
  2469. } else if s, ok := r.(string); ok {
  2470. err = fmt.Errorf("Unexpected panic: %s", s)
  2471. } else {
  2472. err = fmt.Errorf("Unexpected panic: %+v", r)
  2473. }
  2474. }
  2475. }()
  2476. buff := ctx.Buffer
  2477. buff.WriteUInt8(AssetsCodecVersion) // version
  2478. if target.Assets == nil {
  2479. buff.WriteUInt8(uint8(0)) // write nil byte
  2480. } else {
  2481. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2482. // --- [begin][write][slice]([]*AssetSet) ---
  2483. buff.WriteInt(len(target.Assets)) // array length
  2484. for i := 0; i < len(target.Assets); i++ {
  2485. if target.Assets[i] == nil {
  2486. buff.WriteUInt8(uint8(0)) // write nil byte
  2487. } else {
  2488. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2489. // --- [begin][write][struct](AssetSet) ---
  2490. buff.WriteInt(0) // [compatibility, unused]
  2491. errA := target.Assets[i].MarshalBinaryWithContext(ctx)
  2492. if errA != nil {
  2493. return errA
  2494. }
  2495. // --- [end][write][struct](AssetSet) ---
  2496. }
  2497. }
  2498. // --- [end][write][slice]([]*AssetSet) ---
  2499. }
  2500. if ctx.IsStringTable() {
  2501. a := ctx.Table.AddOrGet(target.FromStore)
  2502. buff.WriteInt(a) // write table index
  2503. } else {
  2504. buff.WriteString(target.FromStore) // write string
  2505. }
  2506. return nil
  2507. }
  2508. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2509. // the AssetSetRange type
  2510. func (target *AssetSetRange) UnmarshalBinary(data []byte) error {
  2511. var table []string
  2512. buff := util.NewBufferFromBytes(data)
  2513. // string table header validation
  2514. if isBinaryTag(data, BinaryTagStringTable) {
  2515. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  2516. tl := buff.ReadInt() // table length
  2517. if tl > 0 {
  2518. table = make([]string, tl, tl)
  2519. for i := 0; i < tl; i++ {
  2520. table[i] = buff.ReadString()
  2521. }
  2522. }
  2523. }
  2524. ctx := &DecodingContext{
  2525. Buffer: buff,
  2526. Table: table,
  2527. }
  2528. err := target.UnmarshalBinaryWithContext(ctx)
  2529. if err != nil {
  2530. return err
  2531. }
  2532. return nil
  2533. }
  2534. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2535. // the AssetSetRange type
  2536. func (target *AssetSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2537. // panics are recovered and propagated as errors
  2538. defer func() {
  2539. if r := recover(); r != nil {
  2540. if e, ok := r.(error); ok {
  2541. err = e
  2542. } else if s, ok := r.(string); ok {
  2543. err = fmt.Errorf("Unexpected panic: %s", s)
  2544. } else {
  2545. err = fmt.Errorf("Unexpected panic: %+v", r)
  2546. }
  2547. }
  2548. }()
  2549. buff := ctx.Buffer
  2550. version := buff.ReadUInt8()
  2551. if version > AssetsCodecVersion {
  2552. return fmt.Errorf("Invalid Version Unmarshaling AssetSetRange. Expected %d or less, got %d", AssetsCodecVersion, version)
  2553. }
  2554. if buff.ReadUInt8() == uint8(0) {
  2555. target.Assets = nil
  2556. } else {
  2557. // --- [begin][read][slice]([]*AssetSet) ---
  2558. b := buff.ReadInt() // array len
  2559. a := make([]*AssetSet, b)
  2560. for i := 0; i < b; i++ {
  2561. var c *AssetSet
  2562. if buff.ReadUInt8() == uint8(0) {
  2563. c = nil
  2564. } else {
  2565. // --- [begin][read][struct](AssetSet) ---
  2566. d := &AssetSet{}
  2567. buff.ReadInt() // [compatibility, unused]
  2568. errA := d.UnmarshalBinaryWithContext(ctx)
  2569. if errA != nil {
  2570. return errA
  2571. }
  2572. c = d
  2573. // --- [end][read][struct](AssetSet) ---
  2574. }
  2575. a[i] = c
  2576. }
  2577. target.Assets = a
  2578. // --- [end][read][slice]([]*AssetSet) ---
  2579. }
  2580. var f string
  2581. if ctx.IsStringTable() {
  2582. g := buff.ReadInt() // read string index
  2583. f = ctx.Table[g]
  2584. } else {
  2585. f = buff.ReadString() // read string
  2586. }
  2587. e := f
  2588. target.FromStore = e
  2589. return nil
  2590. }
  2591. //--------------------------------------------------------------------------
  2592. // Breakdown
  2593. //--------------------------------------------------------------------------
  2594. // MarshalBinary serializes the internal properties of this Breakdown instance
  2595. // into a byte array
  2596. func (target *Breakdown) MarshalBinary() (data []byte, err error) {
  2597. ctx := &EncodingContext{
  2598. Buffer: util.NewBuffer(),
  2599. Table: nil,
  2600. }
  2601. e := target.MarshalBinaryWithContext(ctx)
  2602. if e != nil {
  2603. return nil, e
  2604. }
  2605. encBytes := ctx.Buffer.Bytes()
  2606. return encBytes, nil
  2607. }
  2608. // MarshalBinaryWithContext serializes the internal properties of this Breakdown instance
  2609. // into a byte array leveraging a predefined context.
  2610. func (target *Breakdown) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2611. // panics are recovered and propagated as errors
  2612. defer func() {
  2613. if r := recover(); r != nil {
  2614. if e, ok := r.(error); ok {
  2615. err = e
  2616. } else if s, ok := r.(string); ok {
  2617. err = fmt.Errorf("Unexpected panic: %s", s)
  2618. } else {
  2619. err = fmt.Errorf("Unexpected panic: %+v", r)
  2620. }
  2621. }
  2622. }()
  2623. buff := ctx.Buffer
  2624. buff.WriteUInt8(AssetsCodecVersion) // version
  2625. buff.WriteFloat64(target.Idle) // write float64
  2626. buff.WriteFloat64(target.Other) // write float64
  2627. buff.WriteFloat64(target.System) // write float64
  2628. buff.WriteFloat64(target.User) // write float64
  2629. return nil
  2630. }
  2631. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2632. // the Breakdown type
  2633. func (target *Breakdown) UnmarshalBinary(data []byte) error {
  2634. var table []string
  2635. buff := util.NewBufferFromBytes(data)
  2636. // string table header validation
  2637. if isBinaryTag(data, BinaryTagStringTable) {
  2638. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  2639. tl := buff.ReadInt() // table length
  2640. if tl > 0 {
  2641. table = make([]string, tl, tl)
  2642. for i := 0; i < tl; i++ {
  2643. table[i] = buff.ReadString()
  2644. }
  2645. }
  2646. }
  2647. ctx := &DecodingContext{
  2648. Buffer: buff,
  2649. Table: table,
  2650. }
  2651. err := target.UnmarshalBinaryWithContext(ctx)
  2652. if err != nil {
  2653. return err
  2654. }
  2655. return nil
  2656. }
  2657. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2658. // the Breakdown type
  2659. func (target *Breakdown) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2660. // panics are recovered and propagated as errors
  2661. defer func() {
  2662. if r := recover(); r != nil {
  2663. if e, ok := r.(error); ok {
  2664. err = e
  2665. } else if s, ok := r.(string); ok {
  2666. err = fmt.Errorf("Unexpected panic: %s", s)
  2667. } else {
  2668. err = fmt.Errorf("Unexpected panic: %+v", r)
  2669. }
  2670. }
  2671. }()
  2672. buff := ctx.Buffer
  2673. version := buff.ReadUInt8()
  2674. if version > AssetsCodecVersion {
  2675. return fmt.Errorf("Invalid Version Unmarshaling Breakdown. Expected %d or less, got %d", AssetsCodecVersion, version)
  2676. }
  2677. a := buff.ReadFloat64() // read float64
  2678. target.Idle = a
  2679. b := buff.ReadFloat64() // read float64
  2680. target.Other = b
  2681. c := buff.ReadFloat64() // read float64
  2682. target.System = c
  2683. d := buff.ReadFloat64() // read float64
  2684. target.User = d
  2685. return nil
  2686. }
  2687. //--------------------------------------------------------------------------
  2688. // Cloud
  2689. //--------------------------------------------------------------------------
  2690. // MarshalBinary serializes the internal properties of this Cloud instance
  2691. // into a byte array
  2692. func (target *Cloud) MarshalBinary() (data []byte, err error) {
  2693. ctx := &EncodingContext{
  2694. Buffer: util.NewBuffer(),
  2695. Table: nil,
  2696. }
  2697. e := target.MarshalBinaryWithContext(ctx)
  2698. if e != nil {
  2699. return nil, e
  2700. }
  2701. encBytes := ctx.Buffer.Bytes()
  2702. return encBytes, nil
  2703. }
  2704. // MarshalBinaryWithContext serializes the internal properties of this Cloud instance
  2705. // into a byte array leveraging a predefined context.
  2706. func (target *Cloud) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2707. // panics are recovered and propagated as errors
  2708. defer func() {
  2709. if r := recover(); r != nil {
  2710. if e, ok := r.(error); ok {
  2711. err = e
  2712. } else if s, ok := r.(string); ok {
  2713. err = fmt.Errorf("Unexpected panic: %s", s)
  2714. } else {
  2715. err = fmt.Errorf("Unexpected panic: %+v", r)
  2716. }
  2717. }
  2718. }()
  2719. buff := ctx.Buffer
  2720. buff.WriteUInt8(AssetsCodecVersion) // version
  2721. // --- [begin][write][alias](AssetLabels) ---
  2722. if map[string]string(target.Labels) == nil {
  2723. buff.WriteUInt8(uint8(0)) // write nil byte
  2724. } else {
  2725. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2726. // --- [begin][write][map](map[string]string) ---
  2727. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  2728. for v, z := range map[string]string(target.Labels) {
  2729. if ctx.IsStringTable() {
  2730. a := ctx.Table.AddOrGet(v)
  2731. buff.WriteInt(a) // write table index
  2732. } else {
  2733. buff.WriteString(v) // write string
  2734. }
  2735. if ctx.IsStringTable() {
  2736. b := ctx.Table.AddOrGet(z)
  2737. buff.WriteInt(b) // write table index
  2738. } else {
  2739. buff.WriteString(z) // write string
  2740. }
  2741. }
  2742. // --- [end][write][map](map[string]string) ---
  2743. }
  2744. // --- [end][write][alias](AssetLabels) ---
  2745. if target.Properties == nil {
  2746. buff.WriteUInt8(uint8(0)) // write nil byte
  2747. } else {
  2748. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2749. // --- [begin][write][struct](AssetProperties) ---
  2750. buff.WriteInt(0) // [compatibility, unused]
  2751. errA := target.Properties.MarshalBinaryWithContext(ctx)
  2752. if errA != nil {
  2753. return errA
  2754. }
  2755. // --- [end][write][struct](AssetProperties) ---
  2756. }
  2757. // --- [begin][write][reference](time.Time) ---
  2758. c, errB := target.Start.MarshalBinary()
  2759. if errB != nil {
  2760. return errB
  2761. }
  2762. buff.WriteInt(len(c))
  2763. buff.WriteBytes(c)
  2764. // --- [end][write][reference](time.Time) ---
  2765. // --- [begin][write][reference](time.Time) ---
  2766. d, errC := target.End.MarshalBinary()
  2767. if errC != nil {
  2768. return errC
  2769. }
  2770. buff.WriteInt(len(d))
  2771. buff.WriteBytes(d)
  2772. // --- [end][write][reference](time.Time) ---
  2773. // --- [begin][write][struct](Window) ---
  2774. buff.WriteInt(0) // [compatibility, unused]
  2775. errD := target.Window.MarshalBinaryWithContext(ctx)
  2776. if errD != nil {
  2777. return errD
  2778. }
  2779. // --- [end][write][struct](Window) ---
  2780. buff.WriteFloat64(target.Adjustment) // write float64
  2781. buff.WriteFloat64(target.Cost) // write float64
  2782. buff.WriteFloat64(target.Credit) // write float64
  2783. return nil
  2784. }
  2785. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  2786. // the Cloud type
  2787. func (target *Cloud) UnmarshalBinary(data []byte) error {
  2788. var table []string
  2789. buff := util.NewBufferFromBytes(data)
  2790. // string table header validation
  2791. if isBinaryTag(data, BinaryTagStringTable) {
  2792. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  2793. tl := buff.ReadInt() // table length
  2794. if tl > 0 {
  2795. table = make([]string, tl, tl)
  2796. for i := 0; i < tl; i++ {
  2797. table[i] = buff.ReadString()
  2798. }
  2799. }
  2800. }
  2801. ctx := &DecodingContext{
  2802. Buffer: buff,
  2803. Table: table,
  2804. }
  2805. err := target.UnmarshalBinaryWithContext(ctx)
  2806. if err != nil {
  2807. return err
  2808. }
  2809. return nil
  2810. }
  2811. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  2812. // the Cloud type
  2813. func (target *Cloud) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  2814. // panics are recovered and propagated as errors
  2815. defer func() {
  2816. if r := recover(); r != nil {
  2817. if e, ok := r.(error); ok {
  2818. err = e
  2819. } else if s, ok := r.(string); ok {
  2820. err = fmt.Errorf("Unexpected panic: %s", s)
  2821. } else {
  2822. err = fmt.Errorf("Unexpected panic: %+v", r)
  2823. }
  2824. }
  2825. }()
  2826. buff := ctx.Buffer
  2827. version := buff.ReadUInt8()
  2828. if version > AssetsCodecVersion {
  2829. return fmt.Errorf("Invalid Version Unmarshaling Cloud. Expected %d or less, got %d", AssetsCodecVersion, version)
  2830. }
  2831. // --- [begin][read][alias](AssetLabels) ---
  2832. var a map[string]string
  2833. if buff.ReadUInt8() == uint8(0) {
  2834. a = nil
  2835. } else {
  2836. // --- [begin][read][map](map[string]string) ---
  2837. c := buff.ReadInt() // map len
  2838. b := make(map[string]string, c)
  2839. for i := 0; i < c; i++ {
  2840. var v string
  2841. var e string
  2842. if ctx.IsStringTable() {
  2843. f := buff.ReadInt() // read string index
  2844. e = ctx.Table[f]
  2845. } else {
  2846. e = buff.ReadString() // read string
  2847. }
  2848. d := e
  2849. v = d
  2850. var z string
  2851. var h string
  2852. if ctx.IsStringTable() {
  2853. k := buff.ReadInt() // read string index
  2854. h = ctx.Table[k]
  2855. } else {
  2856. h = buff.ReadString() // read string
  2857. }
  2858. g := h
  2859. z = g
  2860. b[v] = z
  2861. }
  2862. a = b
  2863. // --- [end][read][map](map[string]string) ---
  2864. }
  2865. target.Labels = AssetLabels(a)
  2866. // --- [end][read][alias](AssetLabels) ---
  2867. if buff.ReadUInt8() == uint8(0) {
  2868. target.Properties = nil
  2869. } else {
  2870. // --- [begin][read][struct](AssetProperties) ---
  2871. l := &AssetProperties{}
  2872. buff.ReadInt() // [compatibility, unused]
  2873. errA := l.UnmarshalBinaryWithContext(ctx)
  2874. if errA != nil {
  2875. return errA
  2876. }
  2877. target.Properties = l
  2878. // --- [end][read][struct](AssetProperties) ---
  2879. }
  2880. // --- [begin][read][reference](time.Time) ---
  2881. m := &time.Time{}
  2882. n := buff.ReadInt() // byte array length
  2883. o := buff.ReadBytes(n) // byte array
  2884. errB := m.UnmarshalBinary(o)
  2885. if errB != nil {
  2886. return errB
  2887. }
  2888. target.Start = *m
  2889. // --- [end][read][reference](time.Time) ---
  2890. // --- [begin][read][reference](time.Time) ---
  2891. p := &time.Time{}
  2892. q := buff.ReadInt() // byte array length
  2893. r := buff.ReadBytes(q) // byte array
  2894. errC := p.UnmarshalBinary(r)
  2895. if errC != nil {
  2896. return errC
  2897. }
  2898. target.End = *p
  2899. // --- [end][read][reference](time.Time) ---
  2900. // --- [begin][read][struct](Window) ---
  2901. s := &Window{}
  2902. buff.ReadInt() // [compatibility, unused]
  2903. errD := s.UnmarshalBinaryWithContext(ctx)
  2904. if errD != nil {
  2905. return errD
  2906. }
  2907. target.Window = *s
  2908. // --- [end][read][struct](Window) ---
  2909. t := buff.ReadFloat64() // read float64
  2910. target.Adjustment = t
  2911. u := buff.ReadFloat64() // read float64
  2912. target.Cost = u
  2913. w := buff.ReadFloat64() // read float64
  2914. target.Credit = w
  2915. return nil
  2916. }
  2917. //--------------------------------------------------------------------------
  2918. // CloudCost
  2919. //--------------------------------------------------------------------------
  2920. // MarshalBinary serializes the internal properties of this CloudCost instance
  2921. // into a byte array
  2922. func (target *CloudCost) MarshalBinary() (data []byte, err error) {
  2923. ctx := &EncodingContext{
  2924. Buffer: util.NewBuffer(),
  2925. Table: nil,
  2926. }
  2927. e := target.MarshalBinaryWithContext(ctx)
  2928. if e != nil {
  2929. return nil, e
  2930. }
  2931. encBytes := ctx.Buffer.Bytes()
  2932. return encBytes, nil
  2933. }
  2934. // MarshalBinaryWithContext serializes the internal properties of this CloudCost instance
  2935. // into a byte array leveraging a predefined context.
  2936. func (target *CloudCost) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  2937. // panics are recovered and propagated as errors
  2938. defer func() {
  2939. if r := recover(); r != nil {
  2940. if e, ok := r.(error); ok {
  2941. err = e
  2942. } else if s, ok := r.(string); ok {
  2943. err = fmt.Errorf("Unexpected panic: %s", s)
  2944. } else {
  2945. err = fmt.Errorf("Unexpected panic: %+v", r)
  2946. }
  2947. }
  2948. }()
  2949. buff := ctx.Buffer
  2950. buff.WriteUInt8(CloudCostCodecVersion) // version
  2951. if target.Properties == nil {
  2952. buff.WriteUInt8(uint8(0)) // write nil byte
  2953. } else {
  2954. buff.WriteUInt8(uint8(1)) // write non-nil byte
  2955. // --- [begin][write][struct](CloudCostProperties) ---
  2956. buff.WriteInt(0) // [compatibility, unused]
  2957. errA := target.Properties.MarshalBinaryWithContext(ctx)
  2958. if errA != nil {
  2959. return errA
  2960. }
  2961. // --- [end][write][struct](CloudCostProperties) ---
  2962. }
  2963. // --- [begin][write][struct](Window) ---
  2964. buff.WriteInt(0) // [compatibility, unused]
  2965. errB := target.Window.MarshalBinaryWithContext(ctx)
  2966. if errB != nil {
  2967. return errB
  2968. }
  2969. // --- [end][write][struct](Window) ---
  2970. // --- [begin][write][struct](CostMetric) ---
  2971. buff.WriteInt(0) // [compatibility, unused]
  2972. errC := target.ListCost.MarshalBinaryWithContext(ctx)
  2973. if errC != nil {
  2974. return errC
  2975. }
  2976. // --- [end][write][struct](CostMetric) ---
  2977. // --- [begin][write][struct](CostMetric) ---
  2978. buff.WriteInt(0) // [compatibility, unused]
  2979. errD := target.NetCost.MarshalBinaryWithContext(ctx)
  2980. if errD != nil {
  2981. return errD
  2982. }
  2983. // --- [end][write][struct](CostMetric) ---
  2984. // --- [begin][write][struct](CostMetric) ---
  2985. buff.WriteInt(0) // [compatibility, unused]
  2986. errE := target.AmortizedNetCost.MarshalBinaryWithContext(ctx)
  2987. if errE != nil {
  2988. return errE
  2989. }
  2990. // --- [end][write][struct](CostMetric) ---
  2991. // --- [begin][write][struct](CostMetric) ---
  2992. buff.WriteInt(0) // [compatibility, unused]
  2993. errF := target.InvoicedCost.MarshalBinaryWithContext(ctx)
  2994. if errF != nil {
  2995. return errF
  2996. }
  2997. // --- [end][write][struct](CostMetric) ---
  2998. // --- [begin][write][struct](CostMetric) ---
  2999. buff.WriteInt(0) // [compatibility, unused]
  3000. errG := target.AmortizedCost.MarshalBinaryWithContext(ctx)
  3001. if errG != nil {
  3002. return errG
  3003. }
  3004. // --- [end][write][struct](CostMetric) ---
  3005. return nil
  3006. }
  3007. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3008. // the CloudCost type
  3009. func (target *CloudCost) UnmarshalBinary(data []byte) error {
  3010. var table []string
  3011. buff := util.NewBufferFromBytes(data)
  3012. // string table header validation
  3013. if isBinaryTag(data, BinaryTagStringTable) {
  3014. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  3015. tl := buff.ReadInt() // table length
  3016. if tl > 0 {
  3017. table = make([]string, tl, tl)
  3018. for i := 0; i < tl; i++ {
  3019. table[i] = buff.ReadString()
  3020. }
  3021. }
  3022. }
  3023. ctx := &DecodingContext{
  3024. Buffer: buff,
  3025. Table: table,
  3026. }
  3027. err := target.UnmarshalBinaryWithContext(ctx)
  3028. if err != nil {
  3029. return err
  3030. }
  3031. return nil
  3032. }
  3033. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3034. // the CloudCost type
  3035. func (target *CloudCost) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3036. // panics are recovered and propagated as errors
  3037. defer func() {
  3038. if r := recover(); r != nil {
  3039. if e, ok := r.(error); ok {
  3040. err = e
  3041. } else if s, ok := r.(string); ok {
  3042. err = fmt.Errorf("Unexpected panic: %s", s)
  3043. } else {
  3044. err = fmt.Errorf("Unexpected panic: %+v", r)
  3045. }
  3046. }
  3047. }()
  3048. buff := ctx.Buffer
  3049. version := buff.ReadUInt8()
  3050. if version > CloudCostCodecVersion {
  3051. return fmt.Errorf("Invalid Version Unmarshaling CloudCost. Expected %d or less, got %d", CloudCostCodecVersion, version)
  3052. }
  3053. if buff.ReadUInt8() == uint8(0) {
  3054. target.Properties = nil
  3055. } else {
  3056. // --- [begin][read][struct](CloudCostProperties) ---
  3057. a := &CloudCostProperties{}
  3058. buff.ReadInt() // [compatibility, unused]
  3059. errA := a.UnmarshalBinaryWithContext(ctx)
  3060. if errA != nil {
  3061. return errA
  3062. }
  3063. target.Properties = a
  3064. // --- [end][read][struct](CloudCostProperties) ---
  3065. }
  3066. // --- [begin][read][struct](Window) ---
  3067. b := &Window{}
  3068. buff.ReadInt() // [compatibility, unused]
  3069. errB := b.UnmarshalBinaryWithContext(ctx)
  3070. if errB != nil {
  3071. return errB
  3072. }
  3073. target.Window = *b
  3074. // --- [end][read][struct](Window) ---
  3075. // --- [begin][read][struct](CostMetric) ---
  3076. c := &CostMetric{}
  3077. buff.ReadInt() // [compatibility, unused]
  3078. errC := c.UnmarshalBinaryWithContext(ctx)
  3079. if errC != nil {
  3080. return errC
  3081. }
  3082. target.ListCost = *c
  3083. // --- [end][read][struct](CostMetric) ---
  3084. // --- [begin][read][struct](CostMetric) ---
  3085. d := &CostMetric{}
  3086. buff.ReadInt() // [compatibility, unused]
  3087. errD := d.UnmarshalBinaryWithContext(ctx)
  3088. if errD != nil {
  3089. return errD
  3090. }
  3091. target.NetCost = *d
  3092. // --- [end][read][struct](CostMetric) ---
  3093. // --- [begin][read][struct](CostMetric) ---
  3094. e := &CostMetric{}
  3095. buff.ReadInt() // [compatibility, unused]
  3096. errE := e.UnmarshalBinaryWithContext(ctx)
  3097. if errE != nil {
  3098. return errE
  3099. }
  3100. target.AmortizedNetCost = *e
  3101. // --- [end][read][struct](CostMetric) ---
  3102. // --- [begin][read][struct](CostMetric) ---
  3103. f := &CostMetric{}
  3104. buff.ReadInt() // [compatibility, unused]
  3105. errF := f.UnmarshalBinaryWithContext(ctx)
  3106. if errF != nil {
  3107. return errF
  3108. }
  3109. target.InvoicedCost = *f
  3110. // --- [end][read][struct](CostMetric) ---
  3111. // --- [begin][read][struct](CostMetric) ---
  3112. g := &CostMetric{}
  3113. buff.ReadInt() // [compatibility, unused]
  3114. errG := g.UnmarshalBinaryWithContext(ctx)
  3115. if errG != nil {
  3116. return errG
  3117. }
  3118. target.AmortizedCost = *g
  3119. // --- [end][read][struct](CostMetric) ---
  3120. return nil
  3121. }
  3122. //--------------------------------------------------------------------------
  3123. // CloudCostProperties
  3124. //--------------------------------------------------------------------------
  3125. // MarshalBinary serializes the internal properties of this CloudCostProperties instance
  3126. // into a byte array
  3127. func (target *CloudCostProperties) MarshalBinary() (data []byte, err error) {
  3128. ctx := &EncodingContext{
  3129. Buffer: util.NewBuffer(),
  3130. Table: nil,
  3131. }
  3132. e := target.MarshalBinaryWithContext(ctx)
  3133. if e != nil {
  3134. return nil, e
  3135. }
  3136. encBytes := ctx.Buffer.Bytes()
  3137. return encBytes, nil
  3138. }
  3139. // MarshalBinaryWithContext serializes the internal properties of this CloudCostProperties instance
  3140. // into a byte array leveraging a predefined context.
  3141. func (target *CloudCostProperties) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  3142. // panics are recovered and propagated as errors
  3143. defer func() {
  3144. if r := recover(); r != nil {
  3145. if e, ok := r.(error); ok {
  3146. err = e
  3147. } else if s, ok := r.(string); ok {
  3148. err = fmt.Errorf("Unexpected panic: %s", s)
  3149. } else {
  3150. err = fmt.Errorf("Unexpected panic: %+v", r)
  3151. }
  3152. }
  3153. }()
  3154. buff := ctx.Buffer
  3155. buff.WriteUInt8(CloudCostCodecVersion) // version
  3156. if ctx.IsStringTable() {
  3157. a := ctx.Table.AddOrGet(target.ProviderID)
  3158. buff.WriteInt(a) // write table index
  3159. } else {
  3160. buff.WriteString(target.ProviderID) // write string
  3161. }
  3162. if ctx.IsStringTable() {
  3163. b := ctx.Table.AddOrGet(target.Provider)
  3164. buff.WriteInt(b) // write table index
  3165. } else {
  3166. buff.WriteString(target.Provider) // write string
  3167. }
  3168. if ctx.IsStringTable() {
  3169. c := ctx.Table.AddOrGet(target.AccountID)
  3170. buff.WriteInt(c) // write table index
  3171. } else {
  3172. buff.WriteString(target.AccountID) // write string
  3173. }
  3174. if ctx.IsStringTable() {
  3175. d := ctx.Table.AddOrGet(target.AccountName)
  3176. buff.WriteInt(d) // write table index
  3177. } else {
  3178. buff.WriteString(target.AccountName) // write string
  3179. }
  3180. if ctx.IsStringTable() {
  3181. e := ctx.Table.AddOrGet(target.InvoiceEntityID)
  3182. buff.WriteInt(e) // write table index
  3183. } else {
  3184. buff.WriteString(target.InvoiceEntityID) // write string
  3185. }
  3186. if ctx.IsStringTable() {
  3187. f := ctx.Table.AddOrGet(target.InvoiceEntityName)
  3188. buff.WriteInt(f) // write table index
  3189. } else {
  3190. buff.WriteString(target.InvoiceEntityName) // write string
  3191. }
  3192. if ctx.IsStringTable() {
  3193. g := ctx.Table.AddOrGet(target.RegionID)
  3194. buff.WriteInt(g) // write table index
  3195. } else {
  3196. buff.WriteString(target.RegionID) // write string
  3197. }
  3198. if ctx.IsStringTable() {
  3199. h := ctx.Table.AddOrGet(target.AvailabilityZone)
  3200. buff.WriteInt(h) // write table index
  3201. } else {
  3202. buff.WriteString(target.AvailabilityZone) // write string
  3203. }
  3204. if ctx.IsStringTable() {
  3205. k := ctx.Table.AddOrGet(target.Service)
  3206. buff.WriteInt(k) // write table index
  3207. } else {
  3208. buff.WriteString(target.Service) // write string
  3209. }
  3210. if ctx.IsStringTable() {
  3211. l := ctx.Table.AddOrGet(target.Category)
  3212. buff.WriteInt(l) // write table index
  3213. } else {
  3214. buff.WriteString(target.Category) // write string
  3215. }
  3216. // --- [begin][write][alias](CloudCostLabels) ---
  3217. if map[string]string(target.Labels) == nil {
  3218. buff.WriteUInt8(uint8(0)) // write nil byte
  3219. } else {
  3220. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3221. // --- [begin][write][map](map[string]string) ---
  3222. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  3223. for v, z := range map[string]string(target.Labels) {
  3224. if ctx.IsStringTable() {
  3225. m := ctx.Table.AddOrGet(v)
  3226. buff.WriteInt(m) // write table index
  3227. } else {
  3228. buff.WriteString(v) // write string
  3229. }
  3230. if ctx.IsStringTable() {
  3231. n := ctx.Table.AddOrGet(z)
  3232. buff.WriteInt(n) // write table index
  3233. } else {
  3234. buff.WriteString(z) // write string
  3235. }
  3236. }
  3237. // --- [end][write][map](map[string]string) ---
  3238. }
  3239. // --- [end][write][alias](CloudCostLabels) ---
  3240. return nil
  3241. }
  3242. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3243. // the CloudCostProperties type
  3244. func (target *CloudCostProperties) UnmarshalBinary(data []byte) error {
  3245. var table []string
  3246. buff := util.NewBufferFromBytes(data)
  3247. // string table header validation
  3248. if isBinaryTag(data, BinaryTagStringTable) {
  3249. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  3250. tl := buff.ReadInt() // table length
  3251. if tl > 0 {
  3252. table = make([]string, tl, tl)
  3253. for i := 0; i < tl; i++ {
  3254. table[i] = buff.ReadString()
  3255. }
  3256. }
  3257. }
  3258. ctx := &DecodingContext{
  3259. Buffer: buff,
  3260. Table: table,
  3261. }
  3262. err := target.UnmarshalBinaryWithContext(ctx)
  3263. if err != nil {
  3264. return err
  3265. }
  3266. return nil
  3267. }
  3268. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3269. // the CloudCostProperties type
  3270. func (target *CloudCostProperties) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3271. // panics are recovered and propagated as errors
  3272. defer func() {
  3273. if r := recover(); r != nil {
  3274. if e, ok := r.(error); ok {
  3275. err = e
  3276. } else if s, ok := r.(string); ok {
  3277. err = fmt.Errorf("Unexpected panic: %s", s)
  3278. } else {
  3279. err = fmt.Errorf("Unexpected panic: %+v", r)
  3280. }
  3281. }
  3282. }()
  3283. buff := ctx.Buffer
  3284. version := buff.ReadUInt8()
  3285. if version > CloudCostCodecVersion {
  3286. return fmt.Errorf("Invalid Version Unmarshaling CloudCostProperties. Expected %d or less, got %d", CloudCostCodecVersion, version)
  3287. }
  3288. var b string
  3289. if ctx.IsStringTable() {
  3290. c := buff.ReadInt() // read string index
  3291. b = ctx.Table[c]
  3292. } else {
  3293. b = buff.ReadString() // read string
  3294. }
  3295. a := b
  3296. target.ProviderID = a
  3297. var e string
  3298. if ctx.IsStringTable() {
  3299. f := buff.ReadInt() // read string index
  3300. e = ctx.Table[f]
  3301. } else {
  3302. e = buff.ReadString() // read string
  3303. }
  3304. d := e
  3305. target.Provider = d
  3306. var h string
  3307. if ctx.IsStringTable() {
  3308. k := buff.ReadInt() // read string index
  3309. h = ctx.Table[k]
  3310. } else {
  3311. h = buff.ReadString() // read string
  3312. }
  3313. g := h
  3314. target.AccountID = g
  3315. // field version check
  3316. if uint8(3) <= version {
  3317. var m string
  3318. if ctx.IsStringTable() {
  3319. n := buff.ReadInt() // read string index
  3320. m = ctx.Table[n]
  3321. } else {
  3322. m = buff.ReadString() // read string
  3323. }
  3324. l := m
  3325. target.AccountName = l
  3326. } else {
  3327. target.AccountName = "" // default
  3328. }
  3329. var p string
  3330. if ctx.IsStringTable() {
  3331. q := buff.ReadInt() // read string index
  3332. p = ctx.Table[q]
  3333. } else {
  3334. p = buff.ReadString() // read string
  3335. }
  3336. o := p
  3337. target.InvoiceEntityID = o
  3338. // field version check
  3339. if uint8(3) <= version {
  3340. var s string
  3341. if ctx.IsStringTable() {
  3342. t := buff.ReadInt() // read string index
  3343. s = ctx.Table[t]
  3344. } else {
  3345. s = buff.ReadString() // read string
  3346. }
  3347. r := s
  3348. target.InvoiceEntityName = r
  3349. } else {
  3350. target.InvoiceEntityName = "" // default
  3351. }
  3352. // field version check
  3353. if uint8(3) <= version {
  3354. var w string
  3355. if ctx.IsStringTable() {
  3356. x := buff.ReadInt() // read string index
  3357. w = ctx.Table[x]
  3358. } else {
  3359. w = buff.ReadString() // read string
  3360. }
  3361. u := w
  3362. target.RegionID = u
  3363. } else {
  3364. target.RegionID = "" // default
  3365. }
  3366. // field version check
  3367. if uint8(3) <= version {
  3368. var aa string
  3369. if ctx.IsStringTable() {
  3370. bb := buff.ReadInt() // read string index
  3371. aa = ctx.Table[bb]
  3372. } else {
  3373. aa = buff.ReadString() // read string
  3374. }
  3375. y := aa
  3376. target.AvailabilityZone = y
  3377. } else {
  3378. target.AvailabilityZone = "" // default
  3379. }
  3380. var dd string
  3381. if ctx.IsStringTable() {
  3382. ee := buff.ReadInt() // read string index
  3383. dd = ctx.Table[ee]
  3384. } else {
  3385. dd = buff.ReadString() // read string
  3386. }
  3387. cc := dd
  3388. target.Service = cc
  3389. var gg string
  3390. if ctx.IsStringTable() {
  3391. hh := buff.ReadInt() // read string index
  3392. gg = ctx.Table[hh]
  3393. } else {
  3394. gg = buff.ReadString() // read string
  3395. }
  3396. ff := gg
  3397. target.Category = ff
  3398. // --- [begin][read][alias](CloudCostLabels) ---
  3399. var kk map[string]string
  3400. if buff.ReadUInt8() == uint8(0) {
  3401. kk = nil
  3402. } else {
  3403. // --- [begin][read][map](map[string]string) ---
  3404. mm := buff.ReadInt() // map len
  3405. ll := make(map[string]string, mm)
  3406. for i := 0; i < mm; i++ {
  3407. var v string
  3408. var oo string
  3409. if ctx.IsStringTable() {
  3410. pp := buff.ReadInt() // read string index
  3411. oo = ctx.Table[pp]
  3412. } else {
  3413. oo = buff.ReadString() // read string
  3414. }
  3415. nn := oo
  3416. v = nn
  3417. var z string
  3418. var rr string
  3419. if ctx.IsStringTable() {
  3420. ss := buff.ReadInt() // read string index
  3421. rr = ctx.Table[ss]
  3422. } else {
  3423. rr = buff.ReadString() // read string
  3424. }
  3425. qq := rr
  3426. z = qq
  3427. ll[v] = z
  3428. }
  3429. kk = ll
  3430. // --- [end][read][map](map[string]string) ---
  3431. }
  3432. target.Labels = CloudCostLabels(kk)
  3433. // --- [end][read][alias](CloudCostLabels) ---
  3434. return nil
  3435. }
  3436. //--------------------------------------------------------------------------
  3437. // CloudCostSet
  3438. //--------------------------------------------------------------------------
  3439. // MarshalBinary serializes the internal properties of this CloudCostSet instance
  3440. // into a byte array
  3441. func (target *CloudCostSet) MarshalBinary() (data []byte, err error) {
  3442. ctx := &EncodingContext{
  3443. Buffer: util.NewBuffer(),
  3444. Table: NewStringTable(),
  3445. }
  3446. e := target.MarshalBinaryWithContext(ctx)
  3447. if e != nil {
  3448. return nil, e
  3449. }
  3450. encBytes := ctx.Buffer.Bytes()
  3451. sTableBytes := ctx.Table.ToBytes()
  3452. merged := appendBytes(sTableBytes, encBytes)
  3453. return merged, nil
  3454. }
  3455. // MarshalBinaryWithContext serializes the internal properties of this CloudCostSet instance
  3456. // into a byte array leveraging a predefined context.
  3457. func (target *CloudCostSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  3458. // panics are recovered and propagated as errors
  3459. defer func() {
  3460. if r := recover(); r != nil {
  3461. if e, ok := r.(error); ok {
  3462. err = e
  3463. } else if s, ok := r.(string); ok {
  3464. err = fmt.Errorf("Unexpected panic: %s", s)
  3465. } else {
  3466. err = fmt.Errorf("Unexpected panic: %+v", r)
  3467. }
  3468. }
  3469. }()
  3470. buff := ctx.Buffer
  3471. buff.WriteUInt8(CloudCostCodecVersion) // version
  3472. if target.CloudCosts == nil {
  3473. buff.WriteUInt8(uint8(0)) // write nil byte
  3474. } else {
  3475. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3476. // --- [begin][write][map](map[string]*CloudCost) ---
  3477. buff.WriteInt(len(target.CloudCosts)) // map length
  3478. for v, z := range target.CloudCosts {
  3479. if ctx.IsStringTable() {
  3480. a := ctx.Table.AddOrGet(v)
  3481. buff.WriteInt(a) // write table index
  3482. } else {
  3483. buff.WriteString(v) // write string
  3484. }
  3485. if z == nil {
  3486. buff.WriteUInt8(uint8(0)) // write nil byte
  3487. } else {
  3488. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3489. // --- [begin][write][struct](CloudCost) ---
  3490. buff.WriteInt(0) // [compatibility, unused]
  3491. errA := z.MarshalBinaryWithContext(ctx)
  3492. if errA != nil {
  3493. return errA
  3494. }
  3495. // --- [end][write][struct](CloudCost) ---
  3496. }
  3497. }
  3498. // --- [end][write][map](map[string]*CloudCost) ---
  3499. }
  3500. // --- [begin][write][struct](Window) ---
  3501. buff.WriteInt(0) // [compatibility, unused]
  3502. errB := target.Window.MarshalBinaryWithContext(ctx)
  3503. if errB != nil {
  3504. return errB
  3505. }
  3506. // --- [end][write][struct](Window) ---
  3507. if ctx.IsStringTable() {
  3508. b := ctx.Table.AddOrGet(target.Integration)
  3509. buff.WriteInt(b) // write table index
  3510. } else {
  3511. buff.WriteString(target.Integration) // write string
  3512. }
  3513. if target.AggregationProperties == nil {
  3514. buff.WriteUInt8(uint8(0)) // write nil byte
  3515. } else {
  3516. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3517. // --- [begin][write][slice]([]string) ---
  3518. buff.WriteInt(len(target.AggregationProperties)) // array length
  3519. for i := 0; i < len(target.AggregationProperties); i++ {
  3520. if ctx.IsStringTable() {
  3521. c := ctx.Table.AddOrGet(target.AggregationProperties[i])
  3522. buff.WriteInt(c) // write table index
  3523. } else {
  3524. buff.WriteString(target.AggregationProperties[i]) // write string
  3525. }
  3526. }
  3527. // --- [end][write][slice]([]string) ---
  3528. }
  3529. return nil
  3530. }
  3531. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3532. // the CloudCostSet type
  3533. func (target *CloudCostSet) UnmarshalBinary(data []byte) error {
  3534. var table []string
  3535. buff := util.NewBufferFromBytes(data)
  3536. // string table header validation
  3537. if isBinaryTag(data, BinaryTagStringTable) {
  3538. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  3539. tl := buff.ReadInt() // table length
  3540. if tl > 0 {
  3541. table = make([]string, tl, tl)
  3542. for i := 0; i < tl; i++ {
  3543. table[i] = buff.ReadString()
  3544. }
  3545. }
  3546. }
  3547. ctx := &DecodingContext{
  3548. Buffer: buff,
  3549. Table: table,
  3550. }
  3551. err := target.UnmarshalBinaryWithContext(ctx)
  3552. if err != nil {
  3553. return err
  3554. }
  3555. return nil
  3556. }
  3557. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3558. // the CloudCostSet type
  3559. func (target *CloudCostSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3560. // panics are recovered and propagated as errors
  3561. defer func() {
  3562. if r := recover(); r != nil {
  3563. if e, ok := r.(error); ok {
  3564. err = e
  3565. } else if s, ok := r.(string); ok {
  3566. err = fmt.Errorf("Unexpected panic: %s", s)
  3567. } else {
  3568. err = fmt.Errorf("Unexpected panic: %+v", r)
  3569. }
  3570. }
  3571. }()
  3572. buff := ctx.Buffer
  3573. version := buff.ReadUInt8()
  3574. if version > CloudCostCodecVersion {
  3575. return fmt.Errorf("Invalid Version Unmarshaling CloudCostSet. Expected %d or less, got %d", CloudCostCodecVersion, version)
  3576. }
  3577. if buff.ReadUInt8() == uint8(0) {
  3578. target.CloudCosts = nil
  3579. } else {
  3580. // --- [begin][read][map](map[string]*CloudCost) ---
  3581. b := buff.ReadInt() // map len
  3582. a := make(map[string]*CloudCost, b)
  3583. for i := 0; i < b; i++ {
  3584. var v string
  3585. var d string
  3586. if ctx.IsStringTable() {
  3587. e := buff.ReadInt() // read string index
  3588. d = ctx.Table[e]
  3589. } else {
  3590. d = buff.ReadString() // read string
  3591. }
  3592. c := d
  3593. v = c
  3594. var z *CloudCost
  3595. if buff.ReadUInt8() == uint8(0) {
  3596. z = nil
  3597. } else {
  3598. // --- [begin][read][struct](CloudCost) ---
  3599. f := &CloudCost{}
  3600. buff.ReadInt() // [compatibility, unused]
  3601. errA := f.UnmarshalBinaryWithContext(ctx)
  3602. if errA != nil {
  3603. return errA
  3604. }
  3605. z = f
  3606. // --- [end][read][struct](CloudCost) ---
  3607. }
  3608. a[v] = z
  3609. }
  3610. target.CloudCosts = a
  3611. // --- [end][read][map](map[string]*CloudCost) ---
  3612. }
  3613. // --- [begin][read][struct](Window) ---
  3614. g := &Window{}
  3615. buff.ReadInt() // [compatibility, unused]
  3616. errB := g.UnmarshalBinaryWithContext(ctx)
  3617. if errB != nil {
  3618. return errB
  3619. }
  3620. target.Window = *g
  3621. // --- [end][read][struct](Window) ---
  3622. var k string
  3623. if ctx.IsStringTable() {
  3624. l := buff.ReadInt() // read string index
  3625. k = ctx.Table[l]
  3626. } else {
  3627. k = buff.ReadString() // read string
  3628. }
  3629. h := k
  3630. target.Integration = h
  3631. if buff.ReadUInt8() == uint8(0) {
  3632. target.AggregationProperties = nil
  3633. } else {
  3634. // --- [begin][read][slice]([]string) ---
  3635. n := buff.ReadInt() // array len
  3636. m := make([]string, n)
  3637. for j := 0; j < n; j++ {
  3638. var o string
  3639. var q string
  3640. if ctx.IsStringTable() {
  3641. r := buff.ReadInt() // read string index
  3642. q = ctx.Table[r]
  3643. } else {
  3644. q = buff.ReadString() // read string
  3645. }
  3646. p := q
  3647. o = p
  3648. m[j] = o
  3649. }
  3650. target.AggregationProperties = m
  3651. // --- [end][read][slice]([]string) ---
  3652. }
  3653. return nil
  3654. }
  3655. //--------------------------------------------------------------------------
  3656. // CloudCostSetRange
  3657. //--------------------------------------------------------------------------
  3658. // MarshalBinary serializes the internal properties of this CloudCostSetRange instance
  3659. // into a byte array
  3660. func (target *CloudCostSetRange) MarshalBinary() (data []byte, err error) {
  3661. ctx := &EncodingContext{
  3662. Buffer: util.NewBuffer(),
  3663. Table: nil,
  3664. }
  3665. e := target.MarshalBinaryWithContext(ctx)
  3666. if e != nil {
  3667. return nil, e
  3668. }
  3669. encBytes := ctx.Buffer.Bytes()
  3670. return encBytes, nil
  3671. }
  3672. // MarshalBinaryWithContext serializes the internal properties of this CloudCostSetRange instance
  3673. // into a byte array leveraging a predefined context.
  3674. func (target *CloudCostSetRange) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  3675. // panics are recovered and propagated as errors
  3676. defer func() {
  3677. if r := recover(); r != nil {
  3678. if e, ok := r.(error); ok {
  3679. err = e
  3680. } else if s, ok := r.(string); ok {
  3681. err = fmt.Errorf("Unexpected panic: %s", s)
  3682. } else {
  3683. err = fmt.Errorf("Unexpected panic: %+v", r)
  3684. }
  3685. }
  3686. }()
  3687. buff := ctx.Buffer
  3688. buff.WriteUInt8(CloudCostCodecVersion) // version
  3689. if target.CloudCostSets == nil {
  3690. buff.WriteUInt8(uint8(0)) // write nil byte
  3691. } else {
  3692. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3693. // --- [begin][write][slice]([]*CloudCostSet) ---
  3694. buff.WriteInt(len(target.CloudCostSets)) // array length
  3695. for i := 0; i < len(target.CloudCostSets); i++ {
  3696. if target.CloudCostSets[i] == nil {
  3697. buff.WriteUInt8(uint8(0)) // write nil byte
  3698. } else {
  3699. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3700. // --- [begin][write][struct](CloudCostSet) ---
  3701. buff.WriteInt(0) // [compatibility, unused]
  3702. errA := target.CloudCostSets[i].MarshalBinaryWithContext(ctx)
  3703. if errA != nil {
  3704. return errA
  3705. }
  3706. // --- [end][write][struct](CloudCostSet) ---
  3707. }
  3708. }
  3709. // --- [end][write][slice]([]*CloudCostSet) ---
  3710. }
  3711. // --- [begin][write][struct](Window) ---
  3712. buff.WriteInt(0) // [compatibility, unused]
  3713. errB := target.Window.MarshalBinaryWithContext(ctx)
  3714. if errB != nil {
  3715. return errB
  3716. }
  3717. // --- [end][write][struct](Window) ---
  3718. return nil
  3719. }
  3720. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3721. // the CloudCostSetRange type
  3722. func (target *CloudCostSetRange) UnmarshalBinary(data []byte) error {
  3723. var table []string
  3724. buff := util.NewBufferFromBytes(data)
  3725. // string table header validation
  3726. if isBinaryTag(data, BinaryTagStringTable) {
  3727. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  3728. tl := buff.ReadInt() // table length
  3729. if tl > 0 {
  3730. table = make([]string, tl, tl)
  3731. for i := 0; i < tl; i++ {
  3732. table[i] = buff.ReadString()
  3733. }
  3734. }
  3735. }
  3736. ctx := &DecodingContext{
  3737. Buffer: buff,
  3738. Table: table,
  3739. }
  3740. err := target.UnmarshalBinaryWithContext(ctx)
  3741. if err != nil {
  3742. return err
  3743. }
  3744. return nil
  3745. }
  3746. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3747. // the CloudCostSetRange type
  3748. func (target *CloudCostSetRange) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3749. // panics are recovered and propagated as errors
  3750. defer func() {
  3751. if r := recover(); r != nil {
  3752. if e, ok := r.(error); ok {
  3753. err = e
  3754. } else if s, ok := r.(string); ok {
  3755. err = fmt.Errorf("Unexpected panic: %s", s)
  3756. } else {
  3757. err = fmt.Errorf("Unexpected panic: %+v", r)
  3758. }
  3759. }
  3760. }()
  3761. buff := ctx.Buffer
  3762. version := buff.ReadUInt8()
  3763. if version > CloudCostCodecVersion {
  3764. return fmt.Errorf("Invalid Version Unmarshaling CloudCostSetRange. Expected %d or less, got %d", CloudCostCodecVersion, version)
  3765. }
  3766. if buff.ReadUInt8() == uint8(0) {
  3767. target.CloudCostSets = nil
  3768. } else {
  3769. // --- [begin][read][slice]([]*CloudCostSet) ---
  3770. b := buff.ReadInt() // array len
  3771. a := make([]*CloudCostSet, b)
  3772. for i := 0; i < b; i++ {
  3773. var c *CloudCostSet
  3774. if buff.ReadUInt8() == uint8(0) {
  3775. c = nil
  3776. } else {
  3777. // --- [begin][read][struct](CloudCostSet) ---
  3778. d := &CloudCostSet{}
  3779. buff.ReadInt() // [compatibility, unused]
  3780. errA := d.UnmarshalBinaryWithContext(ctx)
  3781. if errA != nil {
  3782. return errA
  3783. }
  3784. c = d
  3785. // --- [end][read][struct](CloudCostSet) ---
  3786. }
  3787. a[i] = c
  3788. }
  3789. target.CloudCostSets = a
  3790. // --- [end][read][slice]([]*CloudCostSet) ---
  3791. }
  3792. // --- [begin][read][struct](Window) ---
  3793. e := &Window{}
  3794. buff.ReadInt() // [compatibility, unused]
  3795. errB := e.UnmarshalBinaryWithContext(ctx)
  3796. if errB != nil {
  3797. return errB
  3798. }
  3799. target.Window = *e
  3800. // --- [end][read][struct](Window) ---
  3801. return nil
  3802. }
  3803. //--------------------------------------------------------------------------
  3804. // ClusterManagement
  3805. //--------------------------------------------------------------------------
  3806. // MarshalBinary serializes the internal properties of this ClusterManagement instance
  3807. // into a byte array
  3808. func (target *ClusterManagement) MarshalBinary() (data []byte, err error) {
  3809. ctx := &EncodingContext{
  3810. Buffer: util.NewBuffer(),
  3811. Table: nil,
  3812. }
  3813. e := target.MarshalBinaryWithContext(ctx)
  3814. if e != nil {
  3815. return nil, e
  3816. }
  3817. encBytes := ctx.Buffer.Bytes()
  3818. return encBytes, nil
  3819. }
  3820. // MarshalBinaryWithContext serializes the internal properties of this ClusterManagement instance
  3821. // into a byte array leveraging a predefined context.
  3822. func (target *ClusterManagement) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  3823. // panics are recovered and propagated as errors
  3824. defer func() {
  3825. if r := recover(); r != nil {
  3826. if e, ok := r.(error); ok {
  3827. err = e
  3828. } else if s, ok := r.(string); ok {
  3829. err = fmt.Errorf("Unexpected panic: %s", s)
  3830. } else {
  3831. err = fmt.Errorf("Unexpected panic: %+v", r)
  3832. }
  3833. }
  3834. }()
  3835. buff := ctx.Buffer
  3836. buff.WriteUInt8(AssetsCodecVersion) // version
  3837. // --- [begin][write][alias](AssetLabels) ---
  3838. if map[string]string(target.Labels) == nil {
  3839. buff.WriteUInt8(uint8(0)) // write nil byte
  3840. } else {
  3841. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3842. // --- [begin][write][map](map[string]string) ---
  3843. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  3844. for v, z := range map[string]string(target.Labels) {
  3845. if ctx.IsStringTable() {
  3846. a := ctx.Table.AddOrGet(v)
  3847. buff.WriteInt(a) // write table index
  3848. } else {
  3849. buff.WriteString(v) // write string
  3850. }
  3851. if ctx.IsStringTable() {
  3852. b := ctx.Table.AddOrGet(z)
  3853. buff.WriteInt(b) // write table index
  3854. } else {
  3855. buff.WriteString(z) // write string
  3856. }
  3857. }
  3858. // --- [end][write][map](map[string]string) ---
  3859. }
  3860. // --- [end][write][alias](AssetLabels) ---
  3861. if target.Properties == nil {
  3862. buff.WriteUInt8(uint8(0)) // write nil byte
  3863. } else {
  3864. buff.WriteUInt8(uint8(1)) // write non-nil byte
  3865. // --- [begin][write][struct](AssetProperties) ---
  3866. buff.WriteInt(0) // [compatibility, unused]
  3867. errA := target.Properties.MarshalBinaryWithContext(ctx)
  3868. if errA != nil {
  3869. return errA
  3870. }
  3871. // --- [end][write][struct](AssetProperties) ---
  3872. }
  3873. // --- [begin][write][struct](Window) ---
  3874. buff.WriteInt(0) // [compatibility, unused]
  3875. errB := target.Window.MarshalBinaryWithContext(ctx)
  3876. if errB != nil {
  3877. return errB
  3878. }
  3879. // --- [end][write][struct](Window) ---
  3880. buff.WriteFloat64(target.Cost) // write float64
  3881. buff.WriteFloat64(target.Adjustment) // write float64
  3882. return nil
  3883. }
  3884. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  3885. // the ClusterManagement type
  3886. func (target *ClusterManagement) UnmarshalBinary(data []byte) error {
  3887. var table []string
  3888. buff := util.NewBufferFromBytes(data)
  3889. // string table header validation
  3890. if isBinaryTag(data, BinaryTagStringTable) {
  3891. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  3892. tl := buff.ReadInt() // table length
  3893. if tl > 0 {
  3894. table = make([]string, tl, tl)
  3895. for i := 0; i < tl; i++ {
  3896. table[i] = buff.ReadString()
  3897. }
  3898. }
  3899. }
  3900. ctx := &DecodingContext{
  3901. Buffer: buff,
  3902. Table: table,
  3903. }
  3904. err := target.UnmarshalBinaryWithContext(ctx)
  3905. if err != nil {
  3906. return err
  3907. }
  3908. return nil
  3909. }
  3910. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  3911. // the ClusterManagement type
  3912. func (target *ClusterManagement) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  3913. // panics are recovered and propagated as errors
  3914. defer func() {
  3915. if r := recover(); r != nil {
  3916. if e, ok := r.(error); ok {
  3917. err = e
  3918. } else if s, ok := r.(string); ok {
  3919. err = fmt.Errorf("Unexpected panic: %s", s)
  3920. } else {
  3921. err = fmt.Errorf("Unexpected panic: %+v", r)
  3922. }
  3923. }
  3924. }()
  3925. buff := ctx.Buffer
  3926. version := buff.ReadUInt8()
  3927. if version > AssetsCodecVersion {
  3928. return fmt.Errorf("Invalid Version Unmarshaling ClusterManagement. Expected %d or less, got %d", AssetsCodecVersion, version)
  3929. }
  3930. // --- [begin][read][alias](AssetLabels) ---
  3931. var a map[string]string
  3932. if buff.ReadUInt8() == uint8(0) {
  3933. a = nil
  3934. } else {
  3935. // --- [begin][read][map](map[string]string) ---
  3936. c := buff.ReadInt() // map len
  3937. b := make(map[string]string, c)
  3938. for i := 0; i < c; i++ {
  3939. var v string
  3940. var e string
  3941. if ctx.IsStringTable() {
  3942. f := buff.ReadInt() // read string index
  3943. e = ctx.Table[f]
  3944. } else {
  3945. e = buff.ReadString() // read string
  3946. }
  3947. d := e
  3948. v = d
  3949. var z string
  3950. var h string
  3951. if ctx.IsStringTable() {
  3952. k := buff.ReadInt() // read string index
  3953. h = ctx.Table[k]
  3954. } else {
  3955. h = buff.ReadString() // read string
  3956. }
  3957. g := h
  3958. z = g
  3959. b[v] = z
  3960. }
  3961. a = b
  3962. // --- [end][read][map](map[string]string) ---
  3963. }
  3964. target.Labels = AssetLabels(a)
  3965. // --- [end][read][alias](AssetLabels) ---
  3966. if buff.ReadUInt8() == uint8(0) {
  3967. target.Properties = nil
  3968. } else {
  3969. // --- [begin][read][struct](AssetProperties) ---
  3970. l := &AssetProperties{}
  3971. buff.ReadInt() // [compatibility, unused]
  3972. errA := l.UnmarshalBinaryWithContext(ctx)
  3973. if errA != nil {
  3974. return errA
  3975. }
  3976. target.Properties = l
  3977. // --- [end][read][struct](AssetProperties) ---
  3978. }
  3979. // --- [begin][read][struct](Window) ---
  3980. m := &Window{}
  3981. buff.ReadInt() // [compatibility, unused]
  3982. errB := m.UnmarshalBinaryWithContext(ctx)
  3983. if errB != nil {
  3984. return errB
  3985. }
  3986. target.Window = *m
  3987. // --- [end][read][struct](Window) ---
  3988. n := buff.ReadFloat64() // read float64
  3989. target.Cost = n
  3990. // field version check
  3991. if uint8(16) <= version {
  3992. o := buff.ReadFloat64() // read float64
  3993. target.Adjustment = o
  3994. } else {
  3995. target.Adjustment = float64(0) // default
  3996. }
  3997. return nil
  3998. }
  3999. //--------------------------------------------------------------------------
  4000. // CostMetric
  4001. //--------------------------------------------------------------------------
  4002. // MarshalBinary serializes the internal properties of this CostMetric instance
  4003. // into a byte array
  4004. func (target *CostMetric) MarshalBinary() (data []byte, err error) {
  4005. ctx := &EncodingContext{
  4006. Buffer: util.NewBuffer(),
  4007. Table: nil,
  4008. }
  4009. e := target.MarshalBinaryWithContext(ctx)
  4010. if e != nil {
  4011. return nil, e
  4012. }
  4013. encBytes := ctx.Buffer.Bytes()
  4014. return encBytes, nil
  4015. }
  4016. // MarshalBinaryWithContext serializes the internal properties of this CostMetric instance
  4017. // into a byte array leveraging a predefined context.
  4018. func (target *CostMetric) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4019. // panics are recovered and propagated as errors
  4020. defer func() {
  4021. if r := recover(); r != nil {
  4022. if e, ok := r.(error); ok {
  4023. err = e
  4024. } else if s, ok := r.(string); ok {
  4025. err = fmt.Errorf("Unexpected panic: %s", s)
  4026. } else {
  4027. err = fmt.Errorf("Unexpected panic: %+v", r)
  4028. }
  4029. }
  4030. }()
  4031. buff := ctx.Buffer
  4032. buff.WriteUInt8(CloudCostCodecVersion) // version
  4033. buff.WriteFloat64(target.Cost) // write float64
  4034. buff.WriteFloat64(target.KubernetesPercent) // write float64
  4035. return nil
  4036. }
  4037. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4038. // the CostMetric type
  4039. func (target *CostMetric) UnmarshalBinary(data []byte) error {
  4040. var table []string
  4041. buff := util.NewBufferFromBytes(data)
  4042. // string table header validation
  4043. if isBinaryTag(data, BinaryTagStringTable) {
  4044. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4045. tl := buff.ReadInt() // table length
  4046. if tl > 0 {
  4047. table = make([]string, tl, tl)
  4048. for i := 0; i < tl; i++ {
  4049. table[i] = buff.ReadString()
  4050. }
  4051. }
  4052. }
  4053. ctx := &DecodingContext{
  4054. Buffer: buff,
  4055. Table: table,
  4056. }
  4057. err := target.UnmarshalBinaryWithContext(ctx)
  4058. if err != nil {
  4059. return err
  4060. }
  4061. return nil
  4062. }
  4063. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4064. // the CostMetric type
  4065. func (target *CostMetric) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4066. // panics are recovered and propagated as errors
  4067. defer func() {
  4068. if r := recover(); r != nil {
  4069. if e, ok := r.(error); ok {
  4070. err = e
  4071. } else if s, ok := r.(string); ok {
  4072. err = fmt.Errorf("Unexpected panic: %s", s)
  4073. } else {
  4074. err = fmt.Errorf("Unexpected panic: %+v", r)
  4075. }
  4076. }
  4077. }()
  4078. buff := ctx.Buffer
  4079. version := buff.ReadUInt8()
  4080. if version > CloudCostCodecVersion {
  4081. return fmt.Errorf("Invalid Version Unmarshaling CostMetric. Expected %d or less, got %d", CloudCostCodecVersion, version)
  4082. }
  4083. a := buff.ReadFloat64() // read float64
  4084. target.Cost = a
  4085. b := buff.ReadFloat64() // read float64
  4086. target.KubernetesPercent = b
  4087. return nil
  4088. }
  4089. //--------------------------------------------------------------------------
  4090. // Disk
  4091. //--------------------------------------------------------------------------
  4092. // MarshalBinary serializes the internal properties of this Disk instance
  4093. // into a byte array
  4094. func (target *Disk) MarshalBinary() (data []byte, err error) {
  4095. ctx := &EncodingContext{
  4096. Buffer: util.NewBuffer(),
  4097. Table: nil,
  4098. }
  4099. e := target.MarshalBinaryWithContext(ctx)
  4100. if e != nil {
  4101. return nil, e
  4102. }
  4103. encBytes := ctx.Buffer.Bytes()
  4104. return encBytes, nil
  4105. }
  4106. // MarshalBinaryWithContext serializes the internal properties of this Disk instance
  4107. // into a byte array leveraging a predefined context.
  4108. func (target *Disk) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4109. // panics are recovered and propagated as errors
  4110. defer func() {
  4111. if r := recover(); r != nil {
  4112. if e, ok := r.(error); ok {
  4113. err = e
  4114. } else if s, ok := r.(string); ok {
  4115. err = fmt.Errorf("Unexpected panic: %s", s)
  4116. } else {
  4117. err = fmt.Errorf("Unexpected panic: %+v", r)
  4118. }
  4119. }
  4120. }()
  4121. buff := ctx.Buffer
  4122. buff.WriteUInt8(AssetsCodecVersion) // version
  4123. // --- [begin][write][alias](AssetLabels) ---
  4124. if map[string]string(target.Labels) == nil {
  4125. buff.WriteUInt8(uint8(0)) // write nil byte
  4126. } else {
  4127. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4128. // --- [begin][write][map](map[string]string) ---
  4129. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  4130. for v, z := range map[string]string(target.Labels) {
  4131. if ctx.IsStringTable() {
  4132. a := ctx.Table.AddOrGet(v)
  4133. buff.WriteInt(a) // write table index
  4134. } else {
  4135. buff.WriteString(v) // write string
  4136. }
  4137. if ctx.IsStringTable() {
  4138. b := ctx.Table.AddOrGet(z)
  4139. buff.WriteInt(b) // write table index
  4140. } else {
  4141. buff.WriteString(z) // write string
  4142. }
  4143. }
  4144. // --- [end][write][map](map[string]string) ---
  4145. }
  4146. // --- [end][write][alias](AssetLabels) ---
  4147. if target.Properties == nil {
  4148. buff.WriteUInt8(uint8(0)) // write nil byte
  4149. } else {
  4150. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4151. // --- [begin][write][struct](AssetProperties) ---
  4152. buff.WriteInt(0) // [compatibility, unused]
  4153. errA := target.Properties.MarshalBinaryWithContext(ctx)
  4154. if errA != nil {
  4155. return errA
  4156. }
  4157. // --- [end][write][struct](AssetProperties) ---
  4158. }
  4159. // --- [begin][write][reference](time.Time) ---
  4160. c, errB := target.Start.MarshalBinary()
  4161. if errB != nil {
  4162. return errB
  4163. }
  4164. buff.WriteInt(len(c))
  4165. buff.WriteBytes(c)
  4166. // --- [end][write][reference](time.Time) ---
  4167. // --- [begin][write][reference](time.Time) ---
  4168. d, errC := target.End.MarshalBinary()
  4169. if errC != nil {
  4170. return errC
  4171. }
  4172. buff.WriteInt(len(d))
  4173. buff.WriteBytes(d)
  4174. // --- [end][write][reference](time.Time) ---
  4175. // --- [begin][write][struct](Window) ---
  4176. buff.WriteInt(0) // [compatibility, unused]
  4177. errD := target.Window.MarshalBinaryWithContext(ctx)
  4178. if errD != nil {
  4179. return errD
  4180. }
  4181. // --- [end][write][struct](Window) ---
  4182. buff.WriteFloat64(target.Adjustment) // write float64
  4183. buff.WriteFloat64(target.Cost) // write float64
  4184. buff.WriteFloat64(target.ByteHours) // write float64
  4185. buff.WriteFloat64(target.Local) // write float64
  4186. if target.Breakdown == nil {
  4187. buff.WriteUInt8(uint8(0)) // write nil byte
  4188. } else {
  4189. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4190. // --- [begin][write][struct](Breakdown) ---
  4191. buff.WriteInt(0) // [compatibility, unused]
  4192. errE := target.Breakdown.MarshalBinaryWithContext(ctx)
  4193. if errE != nil {
  4194. return errE
  4195. }
  4196. // --- [end][write][struct](Breakdown) ---
  4197. }
  4198. if ctx.IsStringTable() {
  4199. e := ctx.Table.AddOrGet(target.StorageClass)
  4200. buff.WriteInt(e) // write table index
  4201. } else {
  4202. buff.WriteString(target.StorageClass) // write string
  4203. }
  4204. if target.ByteHoursUsed == nil {
  4205. buff.WriteUInt8(uint8(0)) // write nil byte
  4206. } else {
  4207. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4208. buff.WriteFloat64(*target.ByteHoursUsed) // write float64
  4209. }
  4210. if target.ByteUsageMax == nil {
  4211. buff.WriteUInt8(uint8(0)) // write nil byte
  4212. } else {
  4213. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4214. buff.WriteFloat64(*target.ByteUsageMax) // write float64
  4215. }
  4216. if ctx.IsStringTable() {
  4217. f := ctx.Table.AddOrGet(target.VolumeName)
  4218. buff.WriteInt(f) // write table index
  4219. } else {
  4220. buff.WriteString(target.VolumeName) // write string
  4221. }
  4222. if ctx.IsStringTable() {
  4223. g := ctx.Table.AddOrGet(target.ClaimName)
  4224. buff.WriteInt(g) // write table index
  4225. } else {
  4226. buff.WriteString(target.ClaimName) // write string
  4227. }
  4228. if ctx.IsStringTable() {
  4229. h := ctx.Table.AddOrGet(target.ClaimNamespace)
  4230. buff.WriteInt(h) // write table index
  4231. } else {
  4232. buff.WriteString(target.ClaimNamespace) // write string
  4233. }
  4234. return nil
  4235. }
  4236. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4237. // the Disk type
  4238. func (target *Disk) UnmarshalBinary(data []byte) error {
  4239. var table []string
  4240. buff := util.NewBufferFromBytes(data)
  4241. // string table header validation
  4242. if isBinaryTag(data, BinaryTagStringTable) {
  4243. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4244. tl := buff.ReadInt() // table length
  4245. if tl > 0 {
  4246. table = make([]string, tl, tl)
  4247. for i := 0; i < tl; i++ {
  4248. table[i] = buff.ReadString()
  4249. }
  4250. }
  4251. }
  4252. ctx := &DecodingContext{
  4253. Buffer: buff,
  4254. Table: table,
  4255. }
  4256. err := target.UnmarshalBinaryWithContext(ctx)
  4257. if err != nil {
  4258. return err
  4259. }
  4260. return nil
  4261. }
  4262. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4263. // the Disk type
  4264. func (target *Disk) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4265. // panics are recovered and propagated as errors
  4266. defer func() {
  4267. if r := recover(); r != nil {
  4268. if e, ok := r.(error); ok {
  4269. err = e
  4270. } else if s, ok := r.(string); ok {
  4271. err = fmt.Errorf("Unexpected panic: %s", s)
  4272. } else {
  4273. err = fmt.Errorf("Unexpected panic: %+v", r)
  4274. }
  4275. }
  4276. }()
  4277. buff := ctx.Buffer
  4278. version := buff.ReadUInt8()
  4279. if version > AssetsCodecVersion {
  4280. return fmt.Errorf("Invalid Version Unmarshaling Disk. Expected %d or less, got %d", AssetsCodecVersion, version)
  4281. }
  4282. // --- [begin][read][alias](AssetLabels) ---
  4283. var a map[string]string
  4284. if buff.ReadUInt8() == uint8(0) {
  4285. a = nil
  4286. } else {
  4287. // --- [begin][read][map](map[string]string) ---
  4288. c := buff.ReadInt() // map len
  4289. b := make(map[string]string, c)
  4290. for i := 0; i < c; i++ {
  4291. var v string
  4292. var e string
  4293. if ctx.IsStringTable() {
  4294. f := buff.ReadInt() // read string index
  4295. e = ctx.Table[f]
  4296. } else {
  4297. e = buff.ReadString() // read string
  4298. }
  4299. d := e
  4300. v = d
  4301. var z string
  4302. var h string
  4303. if ctx.IsStringTable() {
  4304. k := buff.ReadInt() // read string index
  4305. h = ctx.Table[k]
  4306. } else {
  4307. h = buff.ReadString() // read string
  4308. }
  4309. g := h
  4310. z = g
  4311. b[v] = z
  4312. }
  4313. a = b
  4314. // --- [end][read][map](map[string]string) ---
  4315. }
  4316. target.Labels = AssetLabels(a)
  4317. // --- [end][read][alias](AssetLabels) ---
  4318. if buff.ReadUInt8() == uint8(0) {
  4319. target.Properties = nil
  4320. } else {
  4321. // --- [begin][read][struct](AssetProperties) ---
  4322. l := &AssetProperties{}
  4323. buff.ReadInt() // [compatibility, unused]
  4324. errA := l.UnmarshalBinaryWithContext(ctx)
  4325. if errA != nil {
  4326. return errA
  4327. }
  4328. target.Properties = l
  4329. // --- [end][read][struct](AssetProperties) ---
  4330. }
  4331. // --- [begin][read][reference](time.Time) ---
  4332. m := &time.Time{}
  4333. n := buff.ReadInt() // byte array length
  4334. o := buff.ReadBytes(n) // byte array
  4335. errB := m.UnmarshalBinary(o)
  4336. if errB != nil {
  4337. return errB
  4338. }
  4339. target.Start = *m
  4340. // --- [end][read][reference](time.Time) ---
  4341. // --- [begin][read][reference](time.Time) ---
  4342. p := &time.Time{}
  4343. q := buff.ReadInt() // byte array length
  4344. r := buff.ReadBytes(q) // byte array
  4345. errC := p.UnmarshalBinary(r)
  4346. if errC != nil {
  4347. return errC
  4348. }
  4349. target.End = *p
  4350. // --- [end][read][reference](time.Time) ---
  4351. // --- [begin][read][struct](Window) ---
  4352. s := &Window{}
  4353. buff.ReadInt() // [compatibility, unused]
  4354. errD := s.UnmarshalBinaryWithContext(ctx)
  4355. if errD != nil {
  4356. return errD
  4357. }
  4358. target.Window = *s
  4359. // --- [end][read][struct](Window) ---
  4360. t := buff.ReadFloat64() // read float64
  4361. target.Adjustment = t
  4362. u := buff.ReadFloat64() // read float64
  4363. target.Cost = u
  4364. w := buff.ReadFloat64() // read float64
  4365. target.ByteHours = w
  4366. x := buff.ReadFloat64() // read float64
  4367. target.Local = x
  4368. if buff.ReadUInt8() == uint8(0) {
  4369. target.Breakdown = nil
  4370. } else {
  4371. // --- [begin][read][struct](Breakdown) ---
  4372. y := &Breakdown{}
  4373. buff.ReadInt() // [compatibility, unused]
  4374. errE := y.UnmarshalBinaryWithContext(ctx)
  4375. if errE != nil {
  4376. return errE
  4377. }
  4378. target.Breakdown = y
  4379. // --- [end][read][struct](Breakdown) ---
  4380. }
  4381. // field version check
  4382. if uint8(17) <= version {
  4383. var bb string
  4384. if ctx.IsStringTable() {
  4385. cc := buff.ReadInt() // read string index
  4386. bb = ctx.Table[cc]
  4387. } else {
  4388. bb = buff.ReadString() // read string
  4389. }
  4390. aa := bb
  4391. target.StorageClass = aa
  4392. } else {
  4393. target.StorageClass = "" // default
  4394. }
  4395. // field version check
  4396. if uint8(18) <= version {
  4397. if buff.ReadUInt8() == uint8(0) {
  4398. target.ByteHoursUsed = nil
  4399. } else {
  4400. dd := buff.ReadFloat64() // read float64
  4401. target.ByteHoursUsed = &dd
  4402. }
  4403. } else {
  4404. target.ByteHoursUsed = nil
  4405. }
  4406. // field version check
  4407. if uint8(18) <= version {
  4408. if buff.ReadUInt8() == uint8(0) {
  4409. target.ByteUsageMax = nil
  4410. } else {
  4411. ee := buff.ReadFloat64() // read float64
  4412. target.ByteUsageMax = &ee
  4413. }
  4414. } else {
  4415. target.ByteUsageMax = nil
  4416. }
  4417. // field version check
  4418. if uint8(18) <= version {
  4419. var gg string
  4420. if ctx.IsStringTable() {
  4421. hh := buff.ReadInt() // read string index
  4422. gg = ctx.Table[hh]
  4423. } else {
  4424. gg = buff.ReadString() // read string
  4425. }
  4426. ff := gg
  4427. target.VolumeName = ff
  4428. } else {
  4429. target.VolumeName = "" // default
  4430. }
  4431. // field version check
  4432. if uint8(18) <= version {
  4433. var ll string
  4434. if ctx.IsStringTable() {
  4435. mm := buff.ReadInt() // read string index
  4436. ll = ctx.Table[mm]
  4437. } else {
  4438. ll = buff.ReadString() // read string
  4439. }
  4440. kk := ll
  4441. target.ClaimName = kk
  4442. } else {
  4443. target.ClaimName = "" // default
  4444. }
  4445. // field version check
  4446. if uint8(18) <= version {
  4447. var oo string
  4448. if ctx.IsStringTable() {
  4449. pp := buff.ReadInt() // read string index
  4450. oo = ctx.Table[pp]
  4451. } else {
  4452. oo = buff.ReadString() // read string
  4453. }
  4454. nn := oo
  4455. target.ClaimNamespace = nn
  4456. } else {
  4457. target.ClaimNamespace = "" // default
  4458. }
  4459. return nil
  4460. }
  4461. //--------------------------------------------------------------------------
  4462. // GPUAllocation
  4463. //--------------------------------------------------------------------------
  4464. // MarshalBinary serializes the internal properties of this GPUAllocation instance
  4465. // into a byte array
  4466. func (target *GPUAllocation) MarshalBinary() (data []byte, err error) {
  4467. ctx := &EncodingContext{
  4468. Buffer: util.NewBuffer(),
  4469. Table: nil,
  4470. }
  4471. e := target.MarshalBinaryWithContext(ctx)
  4472. if e != nil {
  4473. return nil, e
  4474. }
  4475. encBytes := ctx.Buffer.Bytes()
  4476. return encBytes, nil
  4477. }
  4478. // MarshalBinaryWithContext serializes the internal properties of this GPUAllocation instance
  4479. // into a byte array leveraging a predefined context.
  4480. func (target *GPUAllocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4481. // panics are recovered and propagated as errors
  4482. defer func() {
  4483. if r := recover(); r != nil {
  4484. if e, ok := r.(error); ok {
  4485. err = e
  4486. } else if s, ok := r.(string); ok {
  4487. err = fmt.Errorf("Unexpected panic: %s", s)
  4488. } else {
  4489. err = fmt.Errorf("Unexpected panic: %+v", r)
  4490. }
  4491. }
  4492. }()
  4493. buff := ctx.Buffer
  4494. buff.WriteUInt8(AllocationCodecVersion) // version
  4495. if ctx.IsStringTable() {
  4496. a := ctx.Table.AddOrGet(target.GPUDevice)
  4497. buff.WriteInt(a) // write table index
  4498. } else {
  4499. buff.WriteString(target.GPUDevice) // write string
  4500. }
  4501. if ctx.IsStringTable() {
  4502. b := ctx.Table.AddOrGet(target.GPUModel)
  4503. buff.WriteInt(b) // write table index
  4504. } else {
  4505. buff.WriteString(target.GPUModel) // write string
  4506. }
  4507. if ctx.IsStringTable() {
  4508. c := ctx.Table.AddOrGet(target.GPUUUID)
  4509. buff.WriteInt(c) // write table index
  4510. } else {
  4511. buff.WriteString(target.GPUUUID) // write string
  4512. }
  4513. if target.IsGPUShared == nil {
  4514. buff.WriteUInt8(uint8(0)) // write nil byte
  4515. } else {
  4516. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4517. buff.WriteBool(*target.IsGPUShared) // write bool
  4518. }
  4519. if target.GPUUsageAverage == nil {
  4520. buff.WriteUInt8(uint8(0)) // write nil byte
  4521. } else {
  4522. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4523. buff.WriteFloat64(*target.GPUUsageAverage) // write float64
  4524. }
  4525. if target.GPURequestAverage == nil {
  4526. buff.WriteUInt8(uint8(0)) // write nil byte
  4527. } else {
  4528. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4529. buff.WriteFloat64(*target.GPURequestAverage) // write float64
  4530. }
  4531. return nil
  4532. }
  4533. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4534. // the GPUAllocation type
  4535. func (target *GPUAllocation) UnmarshalBinary(data []byte) error {
  4536. var table []string
  4537. buff := util.NewBufferFromBytes(data)
  4538. // string table header validation
  4539. if isBinaryTag(data, BinaryTagStringTable) {
  4540. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4541. tl := buff.ReadInt() // table length
  4542. if tl > 0 {
  4543. table = make([]string, tl, tl)
  4544. for i := 0; i < tl; i++ {
  4545. table[i] = buff.ReadString()
  4546. }
  4547. }
  4548. }
  4549. ctx := &DecodingContext{
  4550. Buffer: buff,
  4551. Table: table,
  4552. }
  4553. err := target.UnmarshalBinaryWithContext(ctx)
  4554. if err != nil {
  4555. return err
  4556. }
  4557. return nil
  4558. }
  4559. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4560. // the GPUAllocation type
  4561. func (target *GPUAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4562. // panics are recovered and propagated as errors
  4563. defer func() {
  4564. if r := recover(); r != nil {
  4565. if e, ok := r.(error); ok {
  4566. err = e
  4567. } else if s, ok := r.(string); ok {
  4568. err = fmt.Errorf("Unexpected panic: %s", s)
  4569. } else {
  4570. err = fmt.Errorf("Unexpected panic: %+v", r)
  4571. }
  4572. }
  4573. }()
  4574. buff := ctx.Buffer
  4575. version := buff.ReadUInt8()
  4576. if version > AllocationCodecVersion {
  4577. return fmt.Errorf("Invalid Version Unmarshaling GPUAllocation. Expected %d or less, got %d", AllocationCodecVersion, version)
  4578. }
  4579. var b string
  4580. if ctx.IsStringTable() {
  4581. c := buff.ReadInt() // read string index
  4582. b = ctx.Table[c]
  4583. } else {
  4584. b = buff.ReadString() // read string
  4585. }
  4586. a := b
  4587. target.GPUDevice = a
  4588. var e string
  4589. if ctx.IsStringTable() {
  4590. f := buff.ReadInt() // read string index
  4591. e = ctx.Table[f]
  4592. } else {
  4593. e = buff.ReadString() // read string
  4594. }
  4595. d := e
  4596. target.GPUModel = d
  4597. var h string
  4598. if ctx.IsStringTable() {
  4599. k := buff.ReadInt() // read string index
  4600. h = ctx.Table[k]
  4601. } else {
  4602. h = buff.ReadString() // read string
  4603. }
  4604. g := h
  4605. target.GPUUUID = g
  4606. if buff.ReadUInt8() == uint8(0) {
  4607. target.IsGPUShared = nil
  4608. } else {
  4609. l := buff.ReadBool() // read bool
  4610. target.IsGPUShared = &l
  4611. }
  4612. if buff.ReadUInt8() == uint8(0) {
  4613. target.GPUUsageAverage = nil
  4614. } else {
  4615. m := buff.ReadFloat64() // read float64
  4616. target.GPUUsageAverage = &m
  4617. }
  4618. if buff.ReadUInt8() == uint8(0) {
  4619. target.GPURequestAverage = nil
  4620. } else {
  4621. n := buff.ReadFloat64() // read float64
  4622. target.GPURequestAverage = &n
  4623. }
  4624. return nil
  4625. }
  4626. //--------------------------------------------------------------------------
  4627. // LbAllocation
  4628. //--------------------------------------------------------------------------
  4629. // MarshalBinary serializes the internal properties of this LbAllocation instance
  4630. // into a byte array
  4631. func (target *LbAllocation) MarshalBinary() (data []byte, err error) {
  4632. ctx := &EncodingContext{
  4633. Buffer: util.NewBuffer(),
  4634. Table: nil,
  4635. }
  4636. e := target.MarshalBinaryWithContext(ctx)
  4637. if e != nil {
  4638. return nil, e
  4639. }
  4640. encBytes := ctx.Buffer.Bytes()
  4641. return encBytes, nil
  4642. }
  4643. // MarshalBinaryWithContext serializes the internal properties of this LbAllocation instance
  4644. // into a byte array leveraging a predefined context.
  4645. func (target *LbAllocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4646. // panics are recovered and propagated as errors
  4647. defer func() {
  4648. if r := recover(); r != nil {
  4649. if e, ok := r.(error); ok {
  4650. err = e
  4651. } else if s, ok := r.(string); ok {
  4652. err = fmt.Errorf("Unexpected panic: %s", s)
  4653. } else {
  4654. err = fmt.Errorf("Unexpected panic: %+v", r)
  4655. }
  4656. }
  4657. }()
  4658. buff := ctx.Buffer
  4659. buff.WriteUInt8(AllocationCodecVersion) // version
  4660. if ctx.IsStringTable() {
  4661. a := ctx.Table.AddOrGet(target.Service)
  4662. buff.WriteInt(a) // write table index
  4663. } else {
  4664. buff.WriteString(target.Service) // write string
  4665. }
  4666. buff.WriteFloat64(target.Cost) // write float64
  4667. buff.WriteBool(target.Private) // write bool
  4668. if ctx.IsStringTable() {
  4669. b := ctx.Table.AddOrGet(target.Ip)
  4670. buff.WriteInt(b) // write table index
  4671. } else {
  4672. buff.WriteString(target.Ip) // write string
  4673. }
  4674. buff.WriteFloat64(target.Hours) // write float64
  4675. return nil
  4676. }
  4677. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4678. // the LbAllocation type
  4679. func (target *LbAllocation) UnmarshalBinary(data []byte) error {
  4680. var table []string
  4681. buff := util.NewBufferFromBytes(data)
  4682. // string table header validation
  4683. if isBinaryTag(data, BinaryTagStringTable) {
  4684. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4685. tl := buff.ReadInt() // table length
  4686. if tl > 0 {
  4687. table = make([]string, tl, tl)
  4688. for i := 0; i < tl; i++ {
  4689. table[i] = buff.ReadString()
  4690. }
  4691. }
  4692. }
  4693. ctx := &DecodingContext{
  4694. Buffer: buff,
  4695. Table: table,
  4696. }
  4697. err := target.UnmarshalBinaryWithContext(ctx)
  4698. if err != nil {
  4699. return err
  4700. }
  4701. return nil
  4702. }
  4703. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4704. // the LbAllocation type
  4705. func (target *LbAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4706. // panics are recovered and propagated as errors
  4707. defer func() {
  4708. if r := recover(); r != nil {
  4709. if e, ok := r.(error); ok {
  4710. err = e
  4711. } else if s, ok := r.(string); ok {
  4712. err = fmt.Errorf("Unexpected panic: %s", s)
  4713. } else {
  4714. err = fmt.Errorf("Unexpected panic: %+v", r)
  4715. }
  4716. }
  4717. }()
  4718. buff := ctx.Buffer
  4719. version := buff.ReadUInt8()
  4720. if version > AllocationCodecVersion {
  4721. return fmt.Errorf("Invalid Version Unmarshaling LbAllocation. Expected %d or less, got %d", AllocationCodecVersion, version)
  4722. }
  4723. var b string
  4724. if ctx.IsStringTable() {
  4725. c := buff.ReadInt() // read string index
  4726. b = ctx.Table[c]
  4727. } else {
  4728. b = buff.ReadString() // read string
  4729. }
  4730. a := b
  4731. target.Service = a
  4732. d := buff.ReadFloat64() // read float64
  4733. target.Cost = d
  4734. e := buff.ReadBool() // read bool
  4735. target.Private = e
  4736. // field version check
  4737. if uint8(19) <= version {
  4738. var g string
  4739. if ctx.IsStringTable() {
  4740. h := buff.ReadInt() // read string index
  4741. g = ctx.Table[h]
  4742. } else {
  4743. g = buff.ReadString() // read string
  4744. }
  4745. f := g
  4746. target.Ip = f
  4747. } else {
  4748. target.Ip = "" // default
  4749. }
  4750. // field version check
  4751. if uint8(21) <= version {
  4752. k := buff.ReadFloat64() // read float64
  4753. target.Hours = k
  4754. } else {
  4755. target.Hours = float64(0) // default
  4756. }
  4757. return nil
  4758. }
  4759. //--------------------------------------------------------------------------
  4760. // LoadBalancer
  4761. //--------------------------------------------------------------------------
  4762. // MarshalBinary serializes the internal properties of this LoadBalancer instance
  4763. // into a byte array
  4764. func (target *LoadBalancer) MarshalBinary() (data []byte, err error) {
  4765. ctx := &EncodingContext{
  4766. Buffer: util.NewBuffer(),
  4767. Table: nil,
  4768. }
  4769. e := target.MarshalBinaryWithContext(ctx)
  4770. if e != nil {
  4771. return nil, e
  4772. }
  4773. encBytes := ctx.Buffer.Bytes()
  4774. return encBytes, nil
  4775. }
  4776. // MarshalBinaryWithContext serializes the internal properties of this LoadBalancer instance
  4777. // into a byte array leveraging a predefined context.
  4778. func (target *LoadBalancer) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  4779. // panics are recovered and propagated as errors
  4780. defer func() {
  4781. if r := recover(); r != nil {
  4782. if e, ok := r.(error); ok {
  4783. err = e
  4784. } else if s, ok := r.(string); ok {
  4785. err = fmt.Errorf("Unexpected panic: %s", s)
  4786. } else {
  4787. err = fmt.Errorf("Unexpected panic: %+v", r)
  4788. }
  4789. }
  4790. }()
  4791. buff := ctx.Buffer
  4792. buff.WriteUInt8(AssetsCodecVersion) // version
  4793. if target.Properties == nil {
  4794. buff.WriteUInt8(uint8(0)) // write nil byte
  4795. } else {
  4796. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4797. // --- [begin][write][struct](AssetProperties) ---
  4798. buff.WriteInt(0) // [compatibility, unused]
  4799. errA := target.Properties.MarshalBinaryWithContext(ctx)
  4800. if errA != nil {
  4801. return errA
  4802. }
  4803. // --- [end][write][struct](AssetProperties) ---
  4804. }
  4805. // --- [begin][write][alias](AssetLabels) ---
  4806. if map[string]string(target.Labels) == nil {
  4807. buff.WriteUInt8(uint8(0)) // write nil byte
  4808. } else {
  4809. buff.WriteUInt8(uint8(1)) // write non-nil byte
  4810. // --- [begin][write][map](map[string]string) ---
  4811. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  4812. for v, z := range map[string]string(target.Labels) {
  4813. if ctx.IsStringTable() {
  4814. a := ctx.Table.AddOrGet(v)
  4815. buff.WriteInt(a) // write table index
  4816. } else {
  4817. buff.WriteString(v) // write string
  4818. }
  4819. if ctx.IsStringTable() {
  4820. b := ctx.Table.AddOrGet(z)
  4821. buff.WriteInt(b) // write table index
  4822. } else {
  4823. buff.WriteString(z) // write string
  4824. }
  4825. }
  4826. // --- [end][write][map](map[string]string) ---
  4827. }
  4828. // --- [end][write][alias](AssetLabels) ---
  4829. // --- [begin][write][reference](time.Time) ---
  4830. c, errB := target.Start.MarshalBinary()
  4831. if errB != nil {
  4832. return errB
  4833. }
  4834. buff.WriteInt(len(c))
  4835. buff.WriteBytes(c)
  4836. // --- [end][write][reference](time.Time) ---
  4837. // --- [begin][write][reference](time.Time) ---
  4838. d, errC := target.End.MarshalBinary()
  4839. if errC != nil {
  4840. return errC
  4841. }
  4842. buff.WriteInt(len(d))
  4843. buff.WriteBytes(d)
  4844. // --- [end][write][reference](time.Time) ---
  4845. // --- [begin][write][struct](Window) ---
  4846. buff.WriteInt(0) // [compatibility, unused]
  4847. errD := target.Window.MarshalBinaryWithContext(ctx)
  4848. if errD != nil {
  4849. return errD
  4850. }
  4851. // --- [end][write][struct](Window) ---
  4852. buff.WriteFloat64(target.Adjustment) // write float64
  4853. buff.WriteFloat64(target.Cost) // write float64
  4854. buff.WriteBool(target.Private) // write bool
  4855. if ctx.IsStringTable() {
  4856. e := ctx.Table.AddOrGet(target.Ip)
  4857. buff.WriteInt(e) // write table index
  4858. } else {
  4859. buff.WriteString(target.Ip) // write string
  4860. }
  4861. return nil
  4862. }
  4863. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  4864. // the LoadBalancer type
  4865. func (target *LoadBalancer) UnmarshalBinary(data []byte) error {
  4866. var table []string
  4867. buff := util.NewBufferFromBytes(data)
  4868. // string table header validation
  4869. if isBinaryTag(data, BinaryTagStringTable) {
  4870. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  4871. tl := buff.ReadInt() // table length
  4872. if tl > 0 {
  4873. table = make([]string, tl, tl)
  4874. for i := 0; i < tl; i++ {
  4875. table[i] = buff.ReadString()
  4876. }
  4877. }
  4878. }
  4879. ctx := &DecodingContext{
  4880. Buffer: buff,
  4881. Table: table,
  4882. }
  4883. err := target.UnmarshalBinaryWithContext(ctx)
  4884. if err != nil {
  4885. return err
  4886. }
  4887. return nil
  4888. }
  4889. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  4890. // the LoadBalancer type
  4891. func (target *LoadBalancer) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  4892. // panics are recovered and propagated as errors
  4893. defer func() {
  4894. if r := recover(); r != nil {
  4895. if e, ok := r.(error); ok {
  4896. err = e
  4897. } else if s, ok := r.(string); ok {
  4898. err = fmt.Errorf("Unexpected panic: %s", s)
  4899. } else {
  4900. err = fmt.Errorf("Unexpected panic: %+v", r)
  4901. }
  4902. }
  4903. }()
  4904. buff := ctx.Buffer
  4905. version := buff.ReadUInt8()
  4906. if version > AssetsCodecVersion {
  4907. return fmt.Errorf("Invalid Version Unmarshaling LoadBalancer. Expected %d or less, got %d", AssetsCodecVersion, version)
  4908. }
  4909. if buff.ReadUInt8() == uint8(0) {
  4910. target.Properties = nil
  4911. } else {
  4912. // --- [begin][read][struct](AssetProperties) ---
  4913. a := &AssetProperties{}
  4914. buff.ReadInt() // [compatibility, unused]
  4915. errA := a.UnmarshalBinaryWithContext(ctx)
  4916. if errA != nil {
  4917. return errA
  4918. }
  4919. target.Properties = a
  4920. // --- [end][read][struct](AssetProperties) ---
  4921. }
  4922. // --- [begin][read][alias](AssetLabels) ---
  4923. var b map[string]string
  4924. if buff.ReadUInt8() == uint8(0) {
  4925. b = nil
  4926. } else {
  4927. // --- [begin][read][map](map[string]string) ---
  4928. d := buff.ReadInt() // map len
  4929. c := make(map[string]string, d)
  4930. for i := 0; i < d; i++ {
  4931. var v string
  4932. var f string
  4933. if ctx.IsStringTable() {
  4934. g := buff.ReadInt() // read string index
  4935. f = ctx.Table[g]
  4936. } else {
  4937. f = buff.ReadString() // read string
  4938. }
  4939. e := f
  4940. v = e
  4941. var z string
  4942. var k string
  4943. if ctx.IsStringTable() {
  4944. l := buff.ReadInt() // read string index
  4945. k = ctx.Table[l]
  4946. } else {
  4947. k = buff.ReadString() // read string
  4948. }
  4949. h := k
  4950. z = h
  4951. c[v] = z
  4952. }
  4953. b = c
  4954. // --- [end][read][map](map[string]string) ---
  4955. }
  4956. target.Labels = AssetLabels(b)
  4957. // --- [end][read][alias](AssetLabels) ---
  4958. // --- [begin][read][reference](time.Time) ---
  4959. m := &time.Time{}
  4960. n := buff.ReadInt() // byte array length
  4961. o := buff.ReadBytes(n) // byte array
  4962. errB := m.UnmarshalBinary(o)
  4963. if errB != nil {
  4964. return errB
  4965. }
  4966. target.Start = *m
  4967. // --- [end][read][reference](time.Time) ---
  4968. // --- [begin][read][reference](time.Time) ---
  4969. p := &time.Time{}
  4970. q := buff.ReadInt() // byte array length
  4971. r := buff.ReadBytes(q) // byte array
  4972. errC := p.UnmarshalBinary(r)
  4973. if errC != nil {
  4974. return errC
  4975. }
  4976. target.End = *p
  4977. // --- [end][read][reference](time.Time) ---
  4978. // --- [begin][read][struct](Window) ---
  4979. s := &Window{}
  4980. buff.ReadInt() // [compatibility, unused]
  4981. errD := s.UnmarshalBinaryWithContext(ctx)
  4982. if errD != nil {
  4983. return errD
  4984. }
  4985. target.Window = *s
  4986. // --- [end][read][struct](Window) ---
  4987. t := buff.ReadFloat64() // read float64
  4988. target.Adjustment = t
  4989. u := buff.ReadFloat64() // read float64
  4990. target.Cost = u
  4991. // field version check
  4992. if uint8(20) <= version {
  4993. w := buff.ReadBool() // read bool
  4994. target.Private = w
  4995. } else {
  4996. target.Private = false // default
  4997. }
  4998. // field version check
  4999. if uint8(21) <= version {
  5000. var y string
  5001. if ctx.IsStringTable() {
  5002. aa := buff.ReadInt() // read string index
  5003. y = ctx.Table[aa]
  5004. } else {
  5005. y = buff.ReadString() // read string
  5006. }
  5007. x := y
  5008. target.Ip = x
  5009. } else {
  5010. target.Ip = "" // default
  5011. }
  5012. return nil
  5013. }
  5014. //--------------------------------------------------------------------------
  5015. // Network
  5016. //--------------------------------------------------------------------------
  5017. // MarshalBinary serializes the internal properties of this Network instance
  5018. // into a byte array
  5019. func (target *Network) MarshalBinary() (data []byte, err error) {
  5020. ctx := &EncodingContext{
  5021. Buffer: util.NewBuffer(),
  5022. Table: nil,
  5023. }
  5024. e := target.MarshalBinaryWithContext(ctx)
  5025. if e != nil {
  5026. return nil, e
  5027. }
  5028. encBytes := ctx.Buffer.Bytes()
  5029. return encBytes, nil
  5030. }
  5031. // MarshalBinaryWithContext serializes the internal properties of this Network instance
  5032. // into a byte array leveraging a predefined context.
  5033. func (target *Network) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5034. // panics are recovered and propagated as errors
  5035. defer func() {
  5036. if r := recover(); r != nil {
  5037. if e, ok := r.(error); ok {
  5038. err = e
  5039. } else if s, ok := r.(string); ok {
  5040. err = fmt.Errorf("Unexpected panic: %s", s)
  5041. } else {
  5042. err = fmt.Errorf("Unexpected panic: %+v", r)
  5043. }
  5044. }
  5045. }()
  5046. buff := ctx.Buffer
  5047. buff.WriteUInt8(AssetsCodecVersion) // version
  5048. if target.Properties == nil {
  5049. buff.WriteUInt8(uint8(0)) // write nil byte
  5050. } else {
  5051. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5052. // --- [begin][write][struct](AssetProperties) ---
  5053. buff.WriteInt(0) // [compatibility, unused]
  5054. errA := target.Properties.MarshalBinaryWithContext(ctx)
  5055. if errA != nil {
  5056. return errA
  5057. }
  5058. // --- [end][write][struct](AssetProperties) ---
  5059. }
  5060. // --- [begin][write][alias](AssetLabels) ---
  5061. if map[string]string(target.Labels) == nil {
  5062. buff.WriteUInt8(uint8(0)) // write nil byte
  5063. } else {
  5064. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5065. // --- [begin][write][map](map[string]string) ---
  5066. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  5067. for v, z := range map[string]string(target.Labels) {
  5068. if ctx.IsStringTable() {
  5069. a := ctx.Table.AddOrGet(v)
  5070. buff.WriteInt(a) // write table index
  5071. } else {
  5072. buff.WriteString(v) // write string
  5073. }
  5074. if ctx.IsStringTable() {
  5075. b := ctx.Table.AddOrGet(z)
  5076. buff.WriteInt(b) // write table index
  5077. } else {
  5078. buff.WriteString(z) // write string
  5079. }
  5080. }
  5081. // --- [end][write][map](map[string]string) ---
  5082. }
  5083. // --- [end][write][alias](AssetLabels) ---
  5084. // --- [begin][write][reference](time.Time) ---
  5085. c, errB := target.Start.MarshalBinary()
  5086. if errB != nil {
  5087. return errB
  5088. }
  5089. buff.WriteInt(len(c))
  5090. buff.WriteBytes(c)
  5091. // --- [end][write][reference](time.Time) ---
  5092. // --- [begin][write][reference](time.Time) ---
  5093. d, errC := target.End.MarshalBinary()
  5094. if errC != nil {
  5095. return errC
  5096. }
  5097. buff.WriteInt(len(d))
  5098. buff.WriteBytes(d)
  5099. // --- [end][write][reference](time.Time) ---
  5100. // --- [begin][write][struct](Window) ---
  5101. buff.WriteInt(0) // [compatibility, unused]
  5102. errD := target.Window.MarshalBinaryWithContext(ctx)
  5103. if errD != nil {
  5104. return errD
  5105. }
  5106. // --- [end][write][struct](Window) ---
  5107. buff.WriteFloat64(target.Adjustment) // write float64
  5108. buff.WriteFloat64(target.Cost) // write float64
  5109. return nil
  5110. }
  5111. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5112. // the Network type
  5113. func (target *Network) UnmarshalBinary(data []byte) error {
  5114. var table []string
  5115. buff := util.NewBufferFromBytes(data)
  5116. // string table header validation
  5117. if isBinaryTag(data, BinaryTagStringTable) {
  5118. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5119. tl := buff.ReadInt() // table length
  5120. if tl > 0 {
  5121. table = make([]string, tl, tl)
  5122. for i := 0; i < tl; i++ {
  5123. table[i] = buff.ReadString()
  5124. }
  5125. }
  5126. }
  5127. ctx := &DecodingContext{
  5128. Buffer: buff,
  5129. Table: table,
  5130. }
  5131. err := target.UnmarshalBinaryWithContext(ctx)
  5132. if err != nil {
  5133. return err
  5134. }
  5135. return nil
  5136. }
  5137. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5138. // the Network type
  5139. func (target *Network) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5140. // panics are recovered and propagated as errors
  5141. defer func() {
  5142. if r := recover(); r != nil {
  5143. if e, ok := r.(error); ok {
  5144. err = e
  5145. } else if s, ok := r.(string); ok {
  5146. err = fmt.Errorf("Unexpected panic: %s", s)
  5147. } else {
  5148. err = fmt.Errorf("Unexpected panic: %+v", r)
  5149. }
  5150. }
  5151. }()
  5152. buff := ctx.Buffer
  5153. version := buff.ReadUInt8()
  5154. if version > AssetsCodecVersion {
  5155. return fmt.Errorf("Invalid Version Unmarshaling Network. Expected %d or less, got %d", AssetsCodecVersion, version)
  5156. }
  5157. if buff.ReadUInt8() == uint8(0) {
  5158. target.Properties = nil
  5159. } else {
  5160. // --- [begin][read][struct](AssetProperties) ---
  5161. a := &AssetProperties{}
  5162. buff.ReadInt() // [compatibility, unused]
  5163. errA := a.UnmarshalBinaryWithContext(ctx)
  5164. if errA != nil {
  5165. return errA
  5166. }
  5167. target.Properties = a
  5168. // --- [end][read][struct](AssetProperties) ---
  5169. }
  5170. // --- [begin][read][alias](AssetLabels) ---
  5171. var b map[string]string
  5172. if buff.ReadUInt8() == uint8(0) {
  5173. b = nil
  5174. } else {
  5175. // --- [begin][read][map](map[string]string) ---
  5176. d := buff.ReadInt() // map len
  5177. c := make(map[string]string, d)
  5178. for i := 0; i < d; i++ {
  5179. var v string
  5180. var f string
  5181. if ctx.IsStringTable() {
  5182. g := buff.ReadInt() // read string index
  5183. f = ctx.Table[g]
  5184. } else {
  5185. f = buff.ReadString() // read string
  5186. }
  5187. e := f
  5188. v = e
  5189. var z string
  5190. var k string
  5191. if ctx.IsStringTable() {
  5192. l := buff.ReadInt() // read string index
  5193. k = ctx.Table[l]
  5194. } else {
  5195. k = buff.ReadString() // read string
  5196. }
  5197. h := k
  5198. z = h
  5199. c[v] = z
  5200. }
  5201. b = c
  5202. // --- [end][read][map](map[string]string) ---
  5203. }
  5204. target.Labels = AssetLabels(b)
  5205. // --- [end][read][alias](AssetLabels) ---
  5206. // --- [begin][read][reference](time.Time) ---
  5207. m := &time.Time{}
  5208. n := buff.ReadInt() // byte array length
  5209. o := buff.ReadBytes(n) // byte array
  5210. errB := m.UnmarshalBinary(o)
  5211. if errB != nil {
  5212. return errB
  5213. }
  5214. target.Start = *m
  5215. // --- [end][read][reference](time.Time) ---
  5216. // --- [begin][read][reference](time.Time) ---
  5217. p := &time.Time{}
  5218. q := buff.ReadInt() // byte array length
  5219. r := buff.ReadBytes(q) // byte array
  5220. errC := p.UnmarshalBinary(r)
  5221. if errC != nil {
  5222. return errC
  5223. }
  5224. target.End = *p
  5225. // --- [end][read][reference](time.Time) ---
  5226. // --- [begin][read][struct](Window) ---
  5227. s := &Window{}
  5228. buff.ReadInt() // [compatibility, unused]
  5229. errD := s.UnmarshalBinaryWithContext(ctx)
  5230. if errD != nil {
  5231. return errD
  5232. }
  5233. target.Window = *s
  5234. // --- [end][read][struct](Window) ---
  5235. t := buff.ReadFloat64() // read float64
  5236. target.Adjustment = t
  5237. u := buff.ReadFloat64() // read float64
  5238. target.Cost = u
  5239. return nil
  5240. }
  5241. //--------------------------------------------------------------------------
  5242. // NetworkDetail
  5243. //--------------------------------------------------------------------------
  5244. // MarshalBinary serializes the internal properties of this NetworkDetail instance
  5245. // into a byte array
  5246. func (target *NetworkDetail) MarshalBinary() (data []byte, err error) {
  5247. ctx := &EncodingContext{
  5248. Buffer: util.NewBuffer(),
  5249. Table: nil,
  5250. }
  5251. e := target.MarshalBinaryWithContext(ctx)
  5252. if e != nil {
  5253. return nil, e
  5254. }
  5255. encBytes := ctx.Buffer.Bytes()
  5256. return encBytes, nil
  5257. }
  5258. // MarshalBinaryWithContext serializes the internal properties of this NetworkDetail instance
  5259. // into a byte array leveraging a predefined context.
  5260. func (target *NetworkDetail) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5261. // panics are recovered and propagated as errors
  5262. defer func() {
  5263. if r := recover(); r != nil {
  5264. if e, ok := r.(error); ok {
  5265. err = e
  5266. } else if s, ok := r.(string); ok {
  5267. err = fmt.Errorf("Unexpected panic: %s", s)
  5268. } else {
  5269. err = fmt.Errorf("Unexpected panic: %+v", r)
  5270. }
  5271. }
  5272. }()
  5273. buff := ctx.Buffer
  5274. buff.WriteUInt8(NetworkInsightCodecVersion) // version
  5275. buff.WriteFloat64(target.Cost) // write float64
  5276. buff.WriteFloat64(target.Bytes) // write float64
  5277. if ctx.IsStringTable() {
  5278. a := ctx.Table.AddOrGet(target.EndPoint)
  5279. buff.WriteInt(a) // write table index
  5280. } else {
  5281. buff.WriteString(target.EndPoint) // write string
  5282. }
  5283. // --- [begin][write][alias](NetworkTrafficDirection) ---
  5284. if ctx.IsStringTable() {
  5285. b := ctx.Table.AddOrGet(string(target.TrafficDirection))
  5286. buff.WriteInt(b) // write table index
  5287. } else {
  5288. buff.WriteString(string(target.TrafficDirection)) // write string
  5289. }
  5290. // --- [end][write][alias](NetworkTrafficDirection) ---
  5291. // --- [begin][write][alias](NetworkTrafficType) ---
  5292. if ctx.IsStringTable() {
  5293. c := ctx.Table.AddOrGet(string(target.TrafficType))
  5294. buff.WriteInt(c) // write table index
  5295. } else {
  5296. buff.WriteString(string(target.TrafficType)) // write string
  5297. }
  5298. // --- [end][write][alias](NetworkTrafficType) ---
  5299. return nil
  5300. }
  5301. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5302. // the NetworkDetail type
  5303. func (target *NetworkDetail) UnmarshalBinary(data []byte) error {
  5304. var table []string
  5305. buff := util.NewBufferFromBytes(data)
  5306. // string table header validation
  5307. if isBinaryTag(data, BinaryTagStringTable) {
  5308. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5309. tl := buff.ReadInt() // table length
  5310. if tl > 0 {
  5311. table = make([]string, tl, tl)
  5312. for i := 0; i < tl; i++ {
  5313. table[i] = buff.ReadString()
  5314. }
  5315. }
  5316. }
  5317. ctx := &DecodingContext{
  5318. Buffer: buff,
  5319. Table: table,
  5320. }
  5321. err := target.UnmarshalBinaryWithContext(ctx)
  5322. if err != nil {
  5323. return err
  5324. }
  5325. return nil
  5326. }
  5327. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5328. // the NetworkDetail type
  5329. func (target *NetworkDetail) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5330. // panics are recovered and propagated as errors
  5331. defer func() {
  5332. if r := recover(); r != nil {
  5333. if e, ok := r.(error); ok {
  5334. err = e
  5335. } else if s, ok := r.(string); ok {
  5336. err = fmt.Errorf("Unexpected panic: %s", s)
  5337. } else {
  5338. err = fmt.Errorf("Unexpected panic: %+v", r)
  5339. }
  5340. }
  5341. }()
  5342. buff := ctx.Buffer
  5343. version := buff.ReadUInt8()
  5344. if version > NetworkInsightCodecVersion {
  5345. return fmt.Errorf("Invalid Version Unmarshaling NetworkDetail. Expected %d or less, got %d", NetworkInsightCodecVersion, version)
  5346. }
  5347. a := buff.ReadFloat64() // read float64
  5348. target.Cost = a
  5349. b := buff.ReadFloat64() // read float64
  5350. target.Bytes = b
  5351. var d string
  5352. if ctx.IsStringTable() {
  5353. e := buff.ReadInt() // read string index
  5354. d = ctx.Table[e]
  5355. } else {
  5356. d = buff.ReadString() // read string
  5357. }
  5358. c := d
  5359. target.EndPoint = c
  5360. // --- [begin][read][alias](NetworkTrafficDirection) ---
  5361. var f string
  5362. var h string
  5363. if ctx.IsStringTable() {
  5364. k := buff.ReadInt() // read string index
  5365. h = ctx.Table[k]
  5366. } else {
  5367. h = buff.ReadString() // read string
  5368. }
  5369. g := h
  5370. f = g
  5371. target.TrafficDirection = NetworkTrafficDirection(f)
  5372. // --- [end][read][alias](NetworkTrafficDirection) ---
  5373. // --- [begin][read][alias](NetworkTrafficType) ---
  5374. var l string
  5375. var n string
  5376. if ctx.IsStringTable() {
  5377. o := buff.ReadInt() // read string index
  5378. n = ctx.Table[o]
  5379. } else {
  5380. n = buff.ReadString() // read string
  5381. }
  5382. m := n
  5383. l = m
  5384. target.TrafficType = NetworkTrafficType(l)
  5385. // --- [end][read][alias](NetworkTrafficType) ---
  5386. return nil
  5387. }
  5388. //--------------------------------------------------------------------------
  5389. // NetworkInsight
  5390. //--------------------------------------------------------------------------
  5391. // MarshalBinary serializes the internal properties of this NetworkInsight instance
  5392. // into a byte array
  5393. func (target *NetworkInsight) MarshalBinary() (data []byte, err error) {
  5394. ctx := &EncodingContext{
  5395. Buffer: util.NewBuffer(),
  5396. Table: nil,
  5397. }
  5398. e := target.MarshalBinaryWithContext(ctx)
  5399. if e != nil {
  5400. return nil, e
  5401. }
  5402. encBytes := ctx.Buffer.Bytes()
  5403. return encBytes, nil
  5404. }
  5405. // MarshalBinaryWithContext serializes the internal properties of this NetworkInsight instance
  5406. // into a byte array leveraging a predefined context.
  5407. func (target *NetworkInsight) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5408. // panics are recovered and propagated as errors
  5409. defer func() {
  5410. if r := recover(); r != nil {
  5411. if e, ok := r.(error); ok {
  5412. err = e
  5413. } else if s, ok := r.(string); ok {
  5414. err = fmt.Errorf("Unexpected panic: %s", s)
  5415. } else {
  5416. err = fmt.Errorf("Unexpected panic: %+v", r)
  5417. }
  5418. }
  5419. }()
  5420. buff := ctx.Buffer
  5421. buff.WriteUInt8(NetworkInsightCodecVersion) // version
  5422. if ctx.IsStringTable() {
  5423. a := ctx.Table.AddOrGet(target.Cluster)
  5424. buff.WriteInt(a) // write table index
  5425. } else {
  5426. buff.WriteString(target.Cluster) // write string
  5427. }
  5428. if ctx.IsStringTable() {
  5429. b := ctx.Table.AddOrGet(target.Namespace)
  5430. buff.WriteInt(b) // write table index
  5431. } else {
  5432. buff.WriteString(target.Namespace) // write string
  5433. }
  5434. if ctx.IsStringTable() {
  5435. c := ctx.Table.AddOrGet(target.Controller)
  5436. buff.WriteInt(c) // write table index
  5437. } else {
  5438. buff.WriteString(target.Controller) // write string
  5439. }
  5440. if ctx.IsStringTable() {
  5441. d := ctx.Table.AddOrGet(target.Pod)
  5442. buff.WriteInt(d) // write table index
  5443. } else {
  5444. buff.WriteString(target.Pod) // write string
  5445. }
  5446. if ctx.IsStringTable() {
  5447. e := ctx.Table.AddOrGet(target.Node)
  5448. buff.WriteInt(e) // write table index
  5449. } else {
  5450. buff.WriteString(target.Node) // write string
  5451. }
  5452. if target.Labels == nil {
  5453. buff.WriteUInt8(uint8(0)) // write nil byte
  5454. } else {
  5455. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5456. // --- [begin][write][map](map[string]string) ---
  5457. buff.WriteInt(len(target.Labels)) // map length
  5458. for v, z := range target.Labels {
  5459. if ctx.IsStringTable() {
  5460. f := ctx.Table.AddOrGet(v)
  5461. buff.WriteInt(f) // write table index
  5462. } else {
  5463. buff.WriteString(v) // write string
  5464. }
  5465. if ctx.IsStringTable() {
  5466. g := ctx.Table.AddOrGet(z)
  5467. buff.WriteInt(g) // write table index
  5468. } else {
  5469. buff.WriteString(z) // write string
  5470. }
  5471. }
  5472. // --- [end][write][map](map[string]string) ---
  5473. }
  5474. if ctx.IsStringTable() {
  5475. h := ctx.Table.AddOrGet(target.Region)
  5476. buff.WriteInt(h) // write table index
  5477. } else {
  5478. buff.WriteString(target.Region) // write string
  5479. }
  5480. if ctx.IsStringTable() {
  5481. k := ctx.Table.AddOrGet(target.Zone)
  5482. buff.WriteInt(k) // write table index
  5483. } else {
  5484. buff.WriteString(target.Zone) // write string
  5485. }
  5486. buff.WriteFloat64(target.NetworkTotalCost) // write float64
  5487. buff.WriteFloat64(target.NetworkCrossZoneCost) // write float64
  5488. buff.WriteFloat64(target.NetworkCrossRegionCost) // write float64
  5489. buff.WriteFloat64(target.NetworkInternetCost) // write float64
  5490. // --- [begin][write][alias](NetworkDetailsSet) ---
  5491. if map[string]*NetworkDetail(target.NetworkDetails) == nil {
  5492. buff.WriteUInt8(uint8(0)) // write nil byte
  5493. } else {
  5494. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5495. // --- [begin][write][map](map[string]*NetworkDetail) ---
  5496. buff.WriteInt(len(map[string]*NetworkDetail(target.NetworkDetails))) // map length
  5497. for vv, zz := range map[string]*NetworkDetail(target.NetworkDetails) {
  5498. if ctx.IsStringTable() {
  5499. l := ctx.Table.AddOrGet(vv)
  5500. buff.WriteInt(l) // write table index
  5501. } else {
  5502. buff.WriteString(vv) // write string
  5503. }
  5504. if zz == nil {
  5505. buff.WriteUInt8(uint8(0)) // write nil byte
  5506. } else {
  5507. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5508. // --- [begin][write][struct](NetworkDetail) ---
  5509. buff.WriteInt(0) // [compatibility, unused]
  5510. errA := zz.MarshalBinaryWithContext(ctx)
  5511. if errA != nil {
  5512. return errA
  5513. }
  5514. // --- [end][write][struct](NetworkDetail) ---
  5515. }
  5516. }
  5517. // --- [end][write][map](map[string]*NetworkDetail) ---
  5518. }
  5519. // --- [end][write][alias](NetworkDetailsSet) ---
  5520. return nil
  5521. }
  5522. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5523. // the NetworkInsight type
  5524. func (target *NetworkInsight) UnmarshalBinary(data []byte) error {
  5525. var table []string
  5526. buff := util.NewBufferFromBytes(data)
  5527. // string table header validation
  5528. if isBinaryTag(data, BinaryTagStringTable) {
  5529. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5530. tl := buff.ReadInt() // table length
  5531. if tl > 0 {
  5532. table = make([]string, tl, tl)
  5533. for i := 0; i < tl; i++ {
  5534. table[i] = buff.ReadString()
  5535. }
  5536. }
  5537. }
  5538. ctx := &DecodingContext{
  5539. Buffer: buff,
  5540. Table: table,
  5541. }
  5542. err := target.UnmarshalBinaryWithContext(ctx)
  5543. if err != nil {
  5544. return err
  5545. }
  5546. return nil
  5547. }
  5548. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5549. // the NetworkInsight type
  5550. func (target *NetworkInsight) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5551. // panics are recovered and propagated as errors
  5552. defer func() {
  5553. if r := recover(); r != nil {
  5554. if e, ok := r.(error); ok {
  5555. err = e
  5556. } else if s, ok := r.(string); ok {
  5557. err = fmt.Errorf("Unexpected panic: %s", s)
  5558. } else {
  5559. err = fmt.Errorf("Unexpected panic: %+v", r)
  5560. }
  5561. }
  5562. }()
  5563. buff := ctx.Buffer
  5564. version := buff.ReadUInt8()
  5565. if version > NetworkInsightCodecVersion {
  5566. return fmt.Errorf("Invalid Version Unmarshaling NetworkInsight. Expected %d or less, got %d", NetworkInsightCodecVersion, version)
  5567. }
  5568. var b string
  5569. if ctx.IsStringTable() {
  5570. c := buff.ReadInt() // read string index
  5571. b = ctx.Table[c]
  5572. } else {
  5573. b = buff.ReadString() // read string
  5574. }
  5575. a := b
  5576. target.Cluster = a
  5577. var e string
  5578. if ctx.IsStringTable() {
  5579. f := buff.ReadInt() // read string index
  5580. e = ctx.Table[f]
  5581. } else {
  5582. e = buff.ReadString() // read string
  5583. }
  5584. d := e
  5585. target.Namespace = d
  5586. var h string
  5587. if ctx.IsStringTable() {
  5588. k := buff.ReadInt() // read string index
  5589. h = ctx.Table[k]
  5590. } else {
  5591. h = buff.ReadString() // read string
  5592. }
  5593. g := h
  5594. target.Controller = g
  5595. var m string
  5596. if ctx.IsStringTable() {
  5597. n := buff.ReadInt() // read string index
  5598. m = ctx.Table[n]
  5599. } else {
  5600. m = buff.ReadString() // read string
  5601. }
  5602. l := m
  5603. target.Pod = l
  5604. var p string
  5605. if ctx.IsStringTable() {
  5606. q := buff.ReadInt() // read string index
  5607. p = ctx.Table[q]
  5608. } else {
  5609. p = buff.ReadString() // read string
  5610. }
  5611. o := p
  5612. target.Node = o
  5613. if buff.ReadUInt8() == uint8(0) {
  5614. target.Labels = nil
  5615. } else {
  5616. // --- [begin][read][map](map[string]string) ---
  5617. s := buff.ReadInt() // map len
  5618. r := make(map[string]string, s)
  5619. for i := 0; i < s; i++ {
  5620. var v string
  5621. var u string
  5622. if ctx.IsStringTable() {
  5623. w := buff.ReadInt() // read string index
  5624. u = ctx.Table[w]
  5625. } else {
  5626. u = buff.ReadString() // read string
  5627. }
  5628. t := u
  5629. v = t
  5630. var z string
  5631. var y string
  5632. if ctx.IsStringTable() {
  5633. aa := buff.ReadInt() // read string index
  5634. y = ctx.Table[aa]
  5635. } else {
  5636. y = buff.ReadString() // read string
  5637. }
  5638. x := y
  5639. z = x
  5640. r[v] = z
  5641. }
  5642. target.Labels = r
  5643. // --- [end][read][map](map[string]string) ---
  5644. }
  5645. var cc string
  5646. if ctx.IsStringTable() {
  5647. dd := buff.ReadInt() // read string index
  5648. cc = ctx.Table[dd]
  5649. } else {
  5650. cc = buff.ReadString() // read string
  5651. }
  5652. bb := cc
  5653. target.Region = bb
  5654. var ff string
  5655. if ctx.IsStringTable() {
  5656. gg := buff.ReadInt() // read string index
  5657. ff = ctx.Table[gg]
  5658. } else {
  5659. ff = buff.ReadString() // read string
  5660. }
  5661. ee := ff
  5662. target.Zone = ee
  5663. hh := buff.ReadFloat64() // read float64
  5664. target.NetworkTotalCost = hh
  5665. kk := buff.ReadFloat64() // read float64
  5666. target.NetworkCrossZoneCost = kk
  5667. ll := buff.ReadFloat64() // read float64
  5668. target.NetworkCrossRegionCost = ll
  5669. mm := buff.ReadFloat64() // read float64
  5670. target.NetworkInternetCost = mm
  5671. // --- [begin][read][alias](NetworkDetailsSet) ---
  5672. var nn map[string]*NetworkDetail
  5673. if buff.ReadUInt8() == uint8(0) {
  5674. nn = nil
  5675. } else {
  5676. // --- [begin][read][map](map[string]*NetworkDetail) ---
  5677. pp := buff.ReadInt() // map len
  5678. oo := make(map[string]*NetworkDetail, pp)
  5679. for j := 0; j < pp; j++ {
  5680. var vv string
  5681. var rr string
  5682. if ctx.IsStringTable() {
  5683. ss := buff.ReadInt() // read string index
  5684. rr = ctx.Table[ss]
  5685. } else {
  5686. rr = buff.ReadString() // read string
  5687. }
  5688. qq := rr
  5689. vv = qq
  5690. var zz *NetworkDetail
  5691. if buff.ReadUInt8() == uint8(0) {
  5692. zz = nil
  5693. } else {
  5694. // --- [begin][read][struct](NetworkDetail) ---
  5695. tt := &NetworkDetail{}
  5696. buff.ReadInt() // [compatibility, unused]
  5697. errA := tt.UnmarshalBinaryWithContext(ctx)
  5698. if errA != nil {
  5699. return errA
  5700. }
  5701. zz = tt
  5702. // --- [end][read][struct](NetworkDetail) ---
  5703. }
  5704. oo[vv] = zz
  5705. }
  5706. nn = oo
  5707. // --- [end][read][map](map[string]*NetworkDetail) ---
  5708. }
  5709. target.NetworkDetails = NetworkDetailsSet(nn)
  5710. // --- [end][read][alias](NetworkDetailsSet) ---
  5711. return nil
  5712. }
  5713. //--------------------------------------------------------------------------
  5714. // NetworkInsightSet
  5715. //--------------------------------------------------------------------------
  5716. // MarshalBinary serializes the internal properties of this NetworkInsightSet instance
  5717. // into a byte array
  5718. func (target *NetworkInsightSet) MarshalBinary() (data []byte, err error) {
  5719. ctx := &EncodingContext{
  5720. Buffer: util.NewBuffer(),
  5721. Table: nil,
  5722. }
  5723. e := target.MarshalBinaryWithContext(ctx)
  5724. if e != nil {
  5725. return nil, e
  5726. }
  5727. encBytes := ctx.Buffer.Bytes()
  5728. return encBytes, nil
  5729. }
  5730. // MarshalBinaryWithContext serializes the internal properties of this NetworkInsightSet instance
  5731. // into a byte array leveraging a predefined context.
  5732. func (target *NetworkInsightSet) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5733. // panics are recovered and propagated as errors
  5734. defer func() {
  5735. if r := recover(); r != nil {
  5736. if e, ok := r.(error); ok {
  5737. err = e
  5738. } else if s, ok := r.(string); ok {
  5739. err = fmt.Errorf("Unexpected panic: %s", s)
  5740. } else {
  5741. err = fmt.Errorf("Unexpected panic: %+v", r)
  5742. }
  5743. }
  5744. }()
  5745. buff := ctx.Buffer
  5746. buff.WriteUInt8(NetworkInsightCodecVersion) // version
  5747. if target.NetworkInsights == nil {
  5748. buff.WriteUInt8(uint8(0)) // write nil byte
  5749. } else {
  5750. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5751. // --- [begin][write][map](map[string]*NetworkInsight) ---
  5752. buff.WriteInt(len(target.NetworkInsights)) // map length
  5753. for v, z := range target.NetworkInsights {
  5754. if ctx.IsStringTable() {
  5755. a := ctx.Table.AddOrGet(v)
  5756. buff.WriteInt(a) // write table index
  5757. } else {
  5758. buff.WriteString(v) // write string
  5759. }
  5760. if z == nil {
  5761. buff.WriteUInt8(uint8(0)) // write nil byte
  5762. } else {
  5763. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5764. // --- [begin][write][struct](NetworkInsight) ---
  5765. buff.WriteInt(0) // [compatibility, unused]
  5766. errA := z.MarshalBinaryWithContext(ctx)
  5767. if errA != nil {
  5768. return errA
  5769. }
  5770. // --- [end][write][struct](NetworkInsight) ---
  5771. }
  5772. }
  5773. // --- [end][write][map](map[string]*NetworkInsight) ---
  5774. }
  5775. // --- [begin][write][struct](Window) ---
  5776. buff.WriteInt(0) // [compatibility, unused]
  5777. errB := target.Window.MarshalBinaryWithContext(ctx)
  5778. if errB != nil {
  5779. return errB
  5780. }
  5781. // --- [end][write][struct](Window) ---
  5782. return nil
  5783. }
  5784. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  5785. // the NetworkInsightSet type
  5786. func (target *NetworkInsightSet) UnmarshalBinary(data []byte) error {
  5787. var table []string
  5788. buff := util.NewBufferFromBytes(data)
  5789. // string table header validation
  5790. if isBinaryTag(data, BinaryTagStringTable) {
  5791. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  5792. tl := buff.ReadInt() // table length
  5793. if tl > 0 {
  5794. table = make([]string, tl, tl)
  5795. for i := 0; i < tl; i++ {
  5796. table[i] = buff.ReadString()
  5797. }
  5798. }
  5799. }
  5800. ctx := &DecodingContext{
  5801. Buffer: buff,
  5802. Table: table,
  5803. }
  5804. err := target.UnmarshalBinaryWithContext(ctx)
  5805. if err != nil {
  5806. return err
  5807. }
  5808. return nil
  5809. }
  5810. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  5811. // the NetworkInsightSet type
  5812. func (target *NetworkInsightSet) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  5813. // panics are recovered and propagated as errors
  5814. defer func() {
  5815. if r := recover(); r != nil {
  5816. if e, ok := r.(error); ok {
  5817. err = e
  5818. } else if s, ok := r.(string); ok {
  5819. err = fmt.Errorf("Unexpected panic: %s", s)
  5820. } else {
  5821. err = fmt.Errorf("Unexpected panic: %+v", r)
  5822. }
  5823. }
  5824. }()
  5825. buff := ctx.Buffer
  5826. version := buff.ReadUInt8()
  5827. if version > NetworkInsightCodecVersion {
  5828. return fmt.Errorf("Invalid Version Unmarshaling NetworkInsightSet. Expected %d or less, got %d", NetworkInsightCodecVersion, version)
  5829. }
  5830. if buff.ReadUInt8() == uint8(0) {
  5831. target.NetworkInsights = nil
  5832. } else {
  5833. // --- [begin][read][map](map[string]*NetworkInsight) ---
  5834. b := buff.ReadInt() // map len
  5835. a := make(map[string]*NetworkInsight, b)
  5836. for i := 0; i < b; i++ {
  5837. var v string
  5838. var d string
  5839. if ctx.IsStringTable() {
  5840. e := buff.ReadInt() // read string index
  5841. d = ctx.Table[e]
  5842. } else {
  5843. d = buff.ReadString() // read string
  5844. }
  5845. c := d
  5846. v = c
  5847. var z *NetworkInsight
  5848. if buff.ReadUInt8() == uint8(0) {
  5849. z = nil
  5850. } else {
  5851. // --- [begin][read][struct](NetworkInsight) ---
  5852. f := &NetworkInsight{}
  5853. buff.ReadInt() // [compatibility, unused]
  5854. errA := f.UnmarshalBinaryWithContext(ctx)
  5855. if errA != nil {
  5856. return errA
  5857. }
  5858. z = f
  5859. // --- [end][read][struct](NetworkInsight) ---
  5860. }
  5861. a[v] = z
  5862. }
  5863. target.NetworkInsights = a
  5864. // --- [end][read][map](map[string]*NetworkInsight) ---
  5865. }
  5866. // --- [begin][read][struct](Window) ---
  5867. g := &Window{}
  5868. buff.ReadInt() // [compatibility, unused]
  5869. errB := g.UnmarshalBinaryWithContext(ctx)
  5870. if errB != nil {
  5871. return errB
  5872. }
  5873. target.Window = *g
  5874. // --- [end][read][struct](Window) ---
  5875. return nil
  5876. }
  5877. //--------------------------------------------------------------------------
  5878. // Node
  5879. //--------------------------------------------------------------------------
  5880. // MarshalBinary serializes the internal properties of this Node instance
  5881. // into a byte array
  5882. func (target *Node) MarshalBinary() (data []byte, err error) {
  5883. ctx := &EncodingContext{
  5884. Buffer: util.NewBuffer(),
  5885. Table: nil,
  5886. }
  5887. e := target.MarshalBinaryWithContext(ctx)
  5888. if e != nil {
  5889. return nil, e
  5890. }
  5891. encBytes := ctx.Buffer.Bytes()
  5892. return encBytes, nil
  5893. }
  5894. // MarshalBinaryWithContext serializes the internal properties of this Node instance
  5895. // into a byte array leveraging a predefined context.
  5896. func (target *Node) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  5897. // panics are recovered and propagated as errors
  5898. defer func() {
  5899. if r := recover(); r != nil {
  5900. if e, ok := r.(error); ok {
  5901. err = e
  5902. } else if s, ok := r.(string); ok {
  5903. err = fmt.Errorf("Unexpected panic: %s", s)
  5904. } else {
  5905. err = fmt.Errorf("Unexpected panic: %+v", r)
  5906. }
  5907. }
  5908. }()
  5909. buff := ctx.Buffer
  5910. buff.WriteUInt8(AssetsCodecVersion) // version
  5911. if target.Properties == nil {
  5912. buff.WriteUInt8(uint8(0)) // write nil byte
  5913. } else {
  5914. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5915. // --- [begin][write][struct](AssetProperties) ---
  5916. buff.WriteInt(0) // [compatibility, unused]
  5917. errA := target.Properties.MarshalBinaryWithContext(ctx)
  5918. if errA != nil {
  5919. return errA
  5920. }
  5921. // --- [end][write][struct](AssetProperties) ---
  5922. }
  5923. // --- [begin][write][alias](AssetLabels) ---
  5924. if map[string]string(target.Labels) == nil {
  5925. buff.WriteUInt8(uint8(0)) // write nil byte
  5926. } else {
  5927. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5928. // --- [begin][write][map](map[string]string) ---
  5929. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  5930. for v, z := range map[string]string(target.Labels) {
  5931. if ctx.IsStringTable() {
  5932. a := ctx.Table.AddOrGet(v)
  5933. buff.WriteInt(a) // write table index
  5934. } else {
  5935. buff.WriteString(v) // write string
  5936. }
  5937. if ctx.IsStringTable() {
  5938. b := ctx.Table.AddOrGet(z)
  5939. buff.WriteInt(b) // write table index
  5940. } else {
  5941. buff.WriteString(z) // write string
  5942. }
  5943. }
  5944. // --- [end][write][map](map[string]string) ---
  5945. }
  5946. // --- [end][write][alias](AssetLabels) ---
  5947. // --- [begin][write][reference](time.Time) ---
  5948. c, errB := target.Start.MarshalBinary()
  5949. if errB != nil {
  5950. return errB
  5951. }
  5952. buff.WriteInt(len(c))
  5953. buff.WriteBytes(c)
  5954. // --- [end][write][reference](time.Time) ---
  5955. // --- [begin][write][reference](time.Time) ---
  5956. d, errC := target.End.MarshalBinary()
  5957. if errC != nil {
  5958. return errC
  5959. }
  5960. buff.WriteInt(len(d))
  5961. buff.WriteBytes(d)
  5962. // --- [end][write][reference](time.Time) ---
  5963. // --- [begin][write][struct](Window) ---
  5964. buff.WriteInt(0) // [compatibility, unused]
  5965. errD := target.Window.MarshalBinaryWithContext(ctx)
  5966. if errD != nil {
  5967. return errD
  5968. }
  5969. // --- [end][write][struct](Window) ---
  5970. buff.WriteFloat64(target.Adjustment) // write float64
  5971. if ctx.IsStringTable() {
  5972. e := ctx.Table.AddOrGet(target.NodeType)
  5973. buff.WriteInt(e) // write table index
  5974. } else {
  5975. buff.WriteString(target.NodeType) // write string
  5976. }
  5977. buff.WriteFloat64(target.CPUCoreHours) // write float64
  5978. buff.WriteFloat64(target.RAMByteHours) // write float64
  5979. buff.WriteFloat64(target.GPUHours) // write float64
  5980. if target.CPUBreakdown == nil {
  5981. buff.WriteUInt8(uint8(0)) // write nil byte
  5982. } else {
  5983. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5984. // --- [begin][write][struct](Breakdown) ---
  5985. buff.WriteInt(0) // [compatibility, unused]
  5986. errE := target.CPUBreakdown.MarshalBinaryWithContext(ctx)
  5987. if errE != nil {
  5988. return errE
  5989. }
  5990. // --- [end][write][struct](Breakdown) ---
  5991. }
  5992. if target.RAMBreakdown == nil {
  5993. buff.WriteUInt8(uint8(0)) // write nil byte
  5994. } else {
  5995. buff.WriteUInt8(uint8(1)) // write non-nil byte
  5996. // --- [begin][write][struct](Breakdown) ---
  5997. buff.WriteInt(0) // [compatibility, unused]
  5998. errF := target.RAMBreakdown.MarshalBinaryWithContext(ctx)
  5999. if errF != nil {
  6000. return errF
  6001. }
  6002. // --- [end][write][struct](Breakdown) ---
  6003. }
  6004. buff.WriteFloat64(target.CPUCost) // write float64
  6005. buff.WriteFloat64(target.GPUCost) // write float64
  6006. buff.WriteFloat64(target.GPUCount) // write float64
  6007. buff.WriteFloat64(target.RAMCost) // write float64
  6008. buff.WriteFloat64(target.Discount) // write float64
  6009. buff.WriteFloat64(target.Preemptible) // write float64
  6010. if target.Overhead == nil {
  6011. buff.WriteUInt8(uint8(0)) // write nil byte
  6012. } else {
  6013. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6014. // --- [begin][write][struct](NodeOverhead) ---
  6015. buff.WriteInt(0) // [compatibility, unused]
  6016. errG := target.Overhead.MarshalBinaryWithContext(ctx)
  6017. if errG != nil {
  6018. return errG
  6019. }
  6020. // --- [end][write][struct](NodeOverhead) ---
  6021. }
  6022. return nil
  6023. }
  6024. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6025. // the Node type
  6026. func (target *Node) UnmarshalBinary(data []byte) error {
  6027. var table []string
  6028. buff := util.NewBufferFromBytes(data)
  6029. // string table header validation
  6030. if isBinaryTag(data, BinaryTagStringTable) {
  6031. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6032. tl := buff.ReadInt() // table length
  6033. if tl > 0 {
  6034. table = make([]string, tl, tl)
  6035. for i := 0; i < tl; i++ {
  6036. table[i] = buff.ReadString()
  6037. }
  6038. }
  6039. }
  6040. ctx := &DecodingContext{
  6041. Buffer: buff,
  6042. Table: table,
  6043. }
  6044. err := target.UnmarshalBinaryWithContext(ctx)
  6045. if err != nil {
  6046. return err
  6047. }
  6048. return nil
  6049. }
  6050. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6051. // the Node type
  6052. func (target *Node) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6053. // panics are recovered and propagated as errors
  6054. defer func() {
  6055. if r := recover(); r != nil {
  6056. if e, ok := r.(error); ok {
  6057. err = e
  6058. } else if s, ok := r.(string); ok {
  6059. err = fmt.Errorf("Unexpected panic: %s", s)
  6060. } else {
  6061. err = fmt.Errorf("Unexpected panic: %+v", r)
  6062. }
  6063. }
  6064. }()
  6065. buff := ctx.Buffer
  6066. version := buff.ReadUInt8()
  6067. if version > AssetsCodecVersion {
  6068. return fmt.Errorf("Invalid Version Unmarshaling Node. Expected %d or less, got %d", AssetsCodecVersion, version)
  6069. }
  6070. if buff.ReadUInt8() == uint8(0) {
  6071. target.Properties = nil
  6072. } else {
  6073. // --- [begin][read][struct](AssetProperties) ---
  6074. a := &AssetProperties{}
  6075. buff.ReadInt() // [compatibility, unused]
  6076. errA := a.UnmarshalBinaryWithContext(ctx)
  6077. if errA != nil {
  6078. return errA
  6079. }
  6080. target.Properties = a
  6081. // --- [end][read][struct](AssetProperties) ---
  6082. }
  6083. // --- [begin][read][alias](AssetLabels) ---
  6084. var b map[string]string
  6085. if buff.ReadUInt8() == uint8(0) {
  6086. b = nil
  6087. } else {
  6088. // --- [begin][read][map](map[string]string) ---
  6089. d := buff.ReadInt() // map len
  6090. c := make(map[string]string, d)
  6091. for i := 0; i < d; i++ {
  6092. var v string
  6093. var f string
  6094. if ctx.IsStringTable() {
  6095. g := buff.ReadInt() // read string index
  6096. f = ctx.Table[g]
  6097. } else {
  6098. f = buff.ReadString() // read string
  6099. }
  6100. e := f
  6101. v = e
  6102. var z string
  6103. var k string
  6104. if ctx.IsStringTable() {
  6105. l := buff.ReadInt() // read string index
  6106. k = ctx.Table[l]
  6107. } else {
  6108. k = buff.ReadString() // read string
  6109. }
  6110. h := k
  6111. z = h
  6112. c[v] = z
  6113. }
  6114. b = c
  6115. // --- [end][read][map](map[string]string) ---
  6116. }
  6117. target.Labels = AssetLabels(b)
  6118. // --- [end][read][alias](AssetLabels) ---
  6119. // --- [begin][read][reference](time.Time) ---
  6120. m := &time.Time{}
  6121. n := buff.ReadInt() // byte array length
  6122. o := buff.ReadBytes(n) // byte array
  6123. errB := m.UnmarshalBinary(o)
  6124. if errB != nil {
  6125. return errB
  6126. }
  6127. target.Start = *m
  6128. // --- [end][read][reference](time.Time) ---
  6129. // --- [begin][read][reference](time.Time) ---
  6130. p := &time.Time{}
  6131. q := buff.ReadInt() // byte array length
  6132. r := buff.ReadBytes(q) // byte array
  6133. errC := p.UnmarshalBinary(r)
  6134. if errC != nil {
  6135. return errC
  6136. }
  6137. target.End = *p
  6138. // --- [end][read][reference](time.Time) ---
  6139. // --- [begin][read][struct](Window) ---
  6140. s := &Window{}
  6141. buff.ReadInt() // [compatibility, unused]
  6142. errD := s.UnmarshalBinaryWithContext(ctx)
  6143. if errD != nil {
  6144. return errD
  6145. }
  6146. target.Window = *s
  6147. // --- [end][read][struct](Window) ---
  6148. t := buff.ReadFloat64() // read float64
  6149. target.Adjustment = t
  6150. var w string
  6151. if ctx.IsStringTable() {
  6152. x := buff.ReadInt() // read string index
  6153. w = ctx.Table[x]
  6154. } else {
  6155. w = buff.ReadString() // read string
  6156. }
  6157. u := w
  6158. target.NodeType = u
  6159. y := buff.ReadFloat64() // read float64
  6160. target.CPUCoreHours = y
  6161. aa := buff.ReadFloat64() // read float64
  6162. target.RAMByteHours = aa
  6163. bb := buff.ReadFloat64() // read float64
  6164. target.GPUHours = bb
  6165. if buff.ReadUInt8() == uint8(0) {
  6166. target.CPUBreakdown = nil
  6167. } else {
  6168. // --- [begin][read][struct](Breakdown) ---
  6169. cc := &Breakdown{}
  6170. buff.ReadInt() // [compatibility, unused]
  6171. errE := cc.UnmarshalBinaryWithContext(ctx)
  6172. if errE != nil {
  6173. return errE
  6174. }
  6175. target.CPUBreakdown = cc
  6176. // --- [end][read][struct](Breakdown) ---
  6177. }
  6178. if buff.ReadUInt8() == uint8(0) {
  6179. target.RAMBreakdown = nil
  6180. } else {
  6181. // --- [begin][read][struct](Breakdown) ---
  6182. dd := &Breakdown{}
  6183. buff.ReadInt() // [compatibility, unused]
  6184. errF := dd.UnmarshalBinaryWithContext(ctx)
  6185. if errF != nil {
  6186. return errF
  6187. }
  6188. target.RAMBreakdown = dd
  6189. // --- [end][read][struct](Breakdown) ---
  6190. }
  6191. ee := buff.ReadFloat64() // read float64
  6192. target.CPUCost = ee
  6193. ff := buff.ReadFloat64() // read float64
  6194. target.GPUCost = ff
  6195. gg := buff.ReadFloat64() // read float64
  6196. target.GPUCount = gg
  6197. hh := buff.ReadFloat64() // read float64
  6198. target.RAMCost = hh
  6199. kk := buff.ReadFloat64() // read float64
  6200. target.Discount = kk
  6201. ll := buff.ReadFloat64() // read float64
  6202. target.Preemptible = ll
  6203. // field version check
  6204. if uint8(19) <= version {
  6205. if buff.ReadUInt8() == uint8(0) {
  6206. target.Overhead = nil
  6207. } else {
  6208. // --- [begin][read][struct](NodeOverhead) ---
  6209. mm := &NodeOverhead{}
  6210. buff.ReadInt() // [compatibility, unused]
  6211. errG := mm.UnmarshalBinaryWithContext(ctx)
  6212. if errG != nil {
  6213. return errG
  6214. }
  6215. target.Overhead = mm
  6216. // --- [end][read][struct](NodeOverhead) ---
  6217. }
  6218. } else {
  6219. target.Overhead = nil
  6220. }
  6221. return nil
  6222. }
  6223. //--------------------------------------------------------------------------
  6224. // NodeOverhead
  6225. //--------------------------------------------------------------------------
  6226. // MarshalBinary serializes the internal properties of this NodeOverhead instance
  6227. // into a byte array
  6228. func (target *NodeOverhead) MarshalBinary() (data []byte, err error) {
  6229. ctx := &EncodingContext{
  6230. Buffer: util.NewBuffer(),
  6231. Table: nil,
  6232. }
  6233. e := target.MarshalBinaryWithContext(ctx)
  6234. if e != nil {
  6235. return nil, e
  6236. }
  6237. encBytes := ctx.Buffer.Bytes()
  6238. return encBytes, nil
  6239. }
  6240. // MarshalBinaryWithContext serializes the internal properties of this NodeOverhead instance
  6241. // into a byte array leveraging a predefined context.
  6242. func (target *NodeOverhead) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6243. // panics are recovered and propagated as errors
  6244. defer func() {
  6245. if r := recover(); r != nil {
  6246. if e, ok := r.(error); ok {
  6247. err = e
  6248. } else if s, ok := r.(string); ok {
  6249. err = fmt.Errorf("Unexpected panic: %s", s)
  6250. } else {
  6251. err = fmt.Errorf("Unexpected panic: %+v", r)
  6252. }
  6253. }
  6254. }()
  6255. buff := ctx.Buffer
  6256. buff.WriteUInt8(AssetsCodecVersion) // version
  6257. buff.WriteFloat64(target.CpuOverheadFraction) // write float64
  6258. buff.WriteFloat64(target.RamOverheadFraction) // write float64
  6259. buff.WriteFloat64(target.OverheadCostFraction) // write float64
  6260. return nil
  6261. }
  6262. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6263. // the NodeOverhead type
  6264. func (target *NodeOverhead) UnmarshalBinary(data []byte) error {
  6265. var table []string
  6266. buff := util.NewBufferFromBytes(data)
  6267. // string table header validation
  6268. if isBinaryTag(data, BinaryTagStringTable) {
  6269. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6270. tl := buff.ReadInt() // table length
  6271. if tl > 0 {
  6272. table = make([]string, tl, tl)
  6273. for i := 0; i < tl; i++ {
  6274. table[i] = buff.ReadString()
  6275. }
  6276. }
  6277. }
  6278. ctx := &DecodingContext{
  6279. Buffer: buff,
  6280. Table: table,
  6281. }
  6282. err := target.UnmarshalBinaryWithContext(ctx)
  6283. if err != nil {
  6284. return err
  6285. }
  6286. return nil
  6287. }
  6288. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6289. // the NodeOverhead type
  6290. func (target *NodeOverhead) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6291. // panics are recovered and propagated as errors
  6292. defer func() {
  6293. if r := recover(); r != nil {
  6294. if e, ok := r.(error); ok {
  6295. err = e
  6296. } else if s, ok := r.(string); ok {
  6297. err = fmt.Errorf("Unexpected panic: %s", s)
  6298. } else {
  6299. err = fmt.Errorf("Unexpected panic: %+v", r)
  6300. }
  6301. }
  6302. }()
  6303. buff := ctx.Buffer
  6304. version := buff.ReadUInt8()
  6305. if version > AssetsCodecVersion {
  6306. return fmt.Errorf("Invalid Version Unmarshaling NodeOverhead. Expected %d or less, got %d", AssetsCodecVersion, version)
  6307. }
  6308. a := buff.ReadFloat64() // read float64
  6309. target.CpuOverheadFraction = a
  6310. b := buff.ReadFloat64() // read float64
  6311. target.RamOverheadFraction = b
  6312. c := buff.ReadFloat64() // read float64
  6313. target.OverheadCostFraction = c
  6314. return nil
  6315. }
  6316. //--------------------------------------------------------------------------
  6317. // PVAllocation
  6318. //--------------------------------------------------------------------------
  6319. // MarshalBinary serializes the internal properties of this PVAllocation instance
  6320. // into a byte array
  6321. func (target *PVAllocation) MarshalBinary() (data []byte, err error) {
  6322. ctx := &EncodingContext{
  6323. Buffer: util.NewBuffer(),
  6324. Table: nil,
  6325. }
  6326. e := target.MarshalBinaryWithContext(ctx)
  6327. if e != nil {
  6328. return nil, e
  6329. }
  6330. encBytes := ctx.Buffer.Bytes()
  6331. return encBytes, nil
  6332. }
  6333. // MarshalBinaryWithContext serializes the internal properties of this PVAllocation instance
  6334. // into a byte array leveraging a predefined context.
  6335. func (target *PVAllocation) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6336. // panics are recovered and propagated as errors
  6337. defer func() {
  6338. if r := recover(); r != nil {
  6339. if e, ok := r.(error); ok {
  6340. err = e
  6341. } else if s, ok := r.(string); ok {
  6342. err = fmt.Errorf("Unexpected panic: %s", s)
  6343. } else {
  6344. err = fmt.Errorf("Unexpected panic: %+v", r)
  6345. }
  6346. }
  6347. }()
  6348. buff := ctx.Buffer
  6349. buff.WriteUInt8(AllocationCodecVersion) // version
  6350. buff.WriteFloat64(target.ByteHours) // write float64
  6351. buff.WriteFloat64(target.Cost) // write float64
  6352. if ctx.IsStringTable() {
  6353. a := ctx.Table.AddOrGet(target.ProviderID)
  6354. buff.WriteInt(a) // write table index
  6355. } else {
  6356. buff.WriteString(target.ProviderID) // write string
  6357. }
  6358. return nil
  6359. }
  6360. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6361. // the PVAllocation type
  6362. func (target *PVAllocation) UnmarshalBinary(data []byte) error {
  6363. var table []string
  6364. buff := util.NewBufferFromBytes(data)
  6365. // string table header validation
  6366. if isBinaryTag(data, BinaryTagStringTable) {
  6367. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6368. tl := buff.ReadInt() // table length
  6369. if tl > 0 {
  6370. table = make([]string, tl, tl)
  6371. for i := 0; i < tl; i++ {
  6372. table[i] = buff.ReadString()
  6373. }
  6374. }
  6375. }
  6376. ctx := &DecodingContext{
  6377. Buffer: buff,
  6378. Table: table,
  6379. }
  6380. err := target.UnmarshalBinaryWithContext(ctx)
  6381. if err != nil {
  6382. return err
  6383. }
  6384. return nil
  6385. }
  6386. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6387. // the PVAllocation type
  6388. func (target *PVAllocation) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6389. // panics are recovered and propagated as errors
  6390. defer func() {
  6391. if r := recover(); r != nil {
  6392. if e, ok := r.(error); ok {
  6393. err = e
  6394. } else if s, ok := r.(string); ok {
  6395. err = fmt.Errorf("Unexpected panic: %s", s)
  6396. } else {
  6397. err = fmt.Errorf("Unexpected panic: %+v", r)
  6398. }
  6399. }
  6400. }()
  6401. buff := ctx.Buffer
  6402. version := buff.ReadUInt8()
  6403. if version > AllocationCodecVersion {
  6404. return fmt.Errorf("Invalid Version Unmarshaling PVAllocation. Expected %d or less, got %d", AllocationCodecVersion, version)
  6405. }
  6406. a := buff.ReadFloat64() // read float64
  6407. target.ByteHours = a
  6408. b := buff.ReadFloat64() // read float64
  6409. target.Cost = b
  6410. // field version check
  6411. if uint8(20) <= version {
  6412. var d string
  6413. if ctx.IsStringTable() {
  6414. e := buff.ReadInt() // read string index
  6415. d = ctx.Table[e]
  6416. } else {
  6417. d = buff.ReadString() // read string
  6418. }
  6419. c := d
  6420. target.ProviderID = c
  6421. } else {
  6422. target.ProviderID = "" // default
  6423. }
  6424. return nil
  6425. }
  6426. //--------------------------------------------------------------------------
  6427. // PVKey
  6428. //--------------------------------------------------------------------------
  6429. // MarshalBinary serializes the internal properties of this PVKey instance
  6430. // into a byte array
  6431. func (target *PVKey) MarshalBinary() (data []byte, err error) {
  6432. ctx := &EncodingContext{
  6433. Buffer: util.NewBuffer(),
  6434. Table: nil,
  6435. }
  6436. e := target.MarshalBinaryWithContext(ctx)
  6437. if e != nil {
  6438. return nil, e
  6439. }
  6440. encBytes := ctx.Buffer.Bytes()
  6441. return encBytes, nil
  6442. }
  6443. // MarshalBinaryWithContext serializes the internal properties of this PVKey instance
  6444. // into a byte array leveraging a predefined context.
  6445. func (target *PVKey) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6446. // panics are recovered and propagated as errors
  6447. defer func() {
  6448. if r := recover(); r != nil {
  6449. if e, ok := r.(error); ok {
  6450. err = e
  6451. } else if s, ok := r.(string); ok {
  6452. err = fmt.Errorf("Unexpected panic: %s", s)
  6453. } else {
  6454. err = fmt.Errorf("Unexpected panic: %+v", r)
  6455. }
  6456. }
  6457. }()
  6458. buff := ctx.Buffer
  6459. buff.WriteUInt8(AllocationCodecVersion) // version
  6460. if ctx.IsStringTable() {
  6461. a := ctx.Table.AddOrGet(target.Cluster)
  6462. buff.WriteInt(a) // write table index
  6463. } else {
  6464. buff.WriteString(target.Cluster) // write string
  6465. }
  6466. if ctx.IsStringTable() {
  6467. b := ctx.Table.AddOrGet(target.Name)
  6468. buff.WriteInt(b) // write table index
  6469. } else {
  6470. buff.WriteString(target.Name) // write string
  6471. }
  6472. return nil
  6473. }
  6474. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6475. // the PVKey type
  6476. func (target *PVKey) UnmarshalBinary(data []byte) error {
  6477. var table []string
  6478. buff := util.NewBufferFromBytes(data)
  6479. // string table header validation
  6480. if isBinaryTag(data, BinaryTagStringTable) {
  6481. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6482. tl := buff.ReadInt() // table length
  6483. if tl > 0 {
  6484. table = make([]string, tl, tl)
  6485. for i := 0; i < tl; i++ {
  6486. table[i] = buff.ReadString()
  6487. }
  6488. }
  6489. }
  6490. ctx := &DecodingContext{
  6491. Buffer: buff,
  6492. Table: table,
  6493. }
  6494. err := target.UnmarshalBinaryWithContext(ctx)
  6495. if err != nil {
  6496. return err
  6497. }
  6498. return nil
  6499. }
  6500. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6501. // the PVKey type
  6502. func (target *PVKey) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6503. // panics are recovered and propagated as errors
  6504. defer func() {
  6505. if r := recover(); r != nil {
  6506. if e, ok := r.(error); ok {
  6507. err = e
  6508. } else if s, ok := r.(string); ok {
  6509. err = fmt.Errorf("Unexpected panic: %s", s)
  6510. } else {
  6511. err = fmt.Errorf("Unexpected panic: %+v", r)
  6512. }
  6513. }
  6514. }()
  6515. buff := ctx.Buffer
  6516. version := buff.ReadUInt8()
  6517. if version > AllocationCodecVersion {
  6518. return fmt.Errorf("Invalid Version Unmarshaling PVKey. Expected %d or less, got %d", AllocationCodecVersion, version)
  6519. }
  6520. var b string
  6521. if ctx.IsStringTable() {
  6522. c := buff.ReadInt() // read string index
  6523. b = ctx.Table[c]
  6524. } else {
  6525. b = buff.ReadString() // read string
  6526. }
  6527. a := b
  6528. target.Cluster = a
  6529. var e string
  6530. if ctx.IsStringTable() {
  6531. f := buff.ReadInt() // read string index
  6532. e = ctx.Table[f]
  6533. } else {
  6534. e = buff.ReadString() // read string
  6535. }
  6536. d := e
  6537. target.Name = d
  6538. return nil
  6539. }
  6540. //--------------------------------------------------------------------------
  6541. // RawAllocationOnlyData
  6542. //--------------------------------------------------------------------------
  6543. // MarshalBinary serializes the internal properties of this RawAllocationOnlyData instance
  6544. // into a byte array
  6545. func (target *RawAllocationOnlyData) MarshalBinary() (data []byte, err error) {
  6546. ctx := &EncodingContext{
  6547. Buffer: util.NewBuffer(),
  6548. Table: nil,
  6549. }
  6550. e := target.MarshalBinaryWithContext(ctx)
  6551. if e != nil {
  6552. return nil, e
  6553. }
  6554. encBytes := ctx.Buffer.Bytes()
  6555. return encBytes, nil
  6556. }
  6557. // MarshalBinaryWithContext serializes the internal properties of this RawAllocationOnlyData instance
  6558. // into a byte array leveraging a predefined context.
  6559. func (target *RawAllocationOnlyData) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6560. // panics are recovered and propagated as errors
  6561. defer func() {
  6562. if r := recover(); r != nil {
  6563. if e, ok := r.(error); ok {
  6564. err = e
  6565. } else if s, ok := r.(string); ok {
  6566. err = fmt.Errorf("Unexpected panic: %s", s)
  6567. } else {
  6568. err = fmt.Errorf("Unexpected panic: %+v", r)
  6569. }
  6570. }
  6571. }()
  6572. buff := ctx.Buffer
  6573. buff.WriteUInt8(AllocationCodecVersion) // version
  6574. buff.WriteFloat64(target.CPUCoreUsageMax) // write float64
  6575. buff.WriteFloat64(target.RAMBytesUsageMax) // write float64
  6576. if target.GPUUsageMax == nil {
  6577. buff.WriteUInt8(uint8(0)) // write nil byte
  6578. } else {
  6579. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6580. buff.WriteFloat64(*target.GPUUsageMax) // write float64
  6581. }
  6582. return nil
  6583. }
  6584. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6585. // the RawAllocationOnlyData type
  6586. func (target *RawAllocationOnlyData) UnmarshalBinary(data []byte) error {
  6587. var table []string
  6588. buff := util.NewBufferFromBytes(data)
  6589. // string table header validation
  6590. if isBinaryTag(data, BinaryTagStringTable) {
  6591. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6592. tl := buff.ReadInt() // table length
  6593. if tl > 0 {
  6594. table = make([]string, tl, tl)
  6595. for i := 0; i < tl; i++ {
  6596. table[i] = buff.ReadString()
  6597. }
  6598. }
  6599. }
  6600. ctx := &DecodingContext{
  6601. Buffer: buff,
  6602. Table: table,
  6603. }
  6604. err := target.UnmarshalBinaryWithContext(ctx)
  6605. if err != nil {
  6606. return err
  6607. }
  6608. return nil
  6609. }
  6610. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6611. // the RawAllocationOnlyData type
  6612. func (target *RawAllocationOnlyData) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6613. // panics are recovered and propagated as errors
  6614. defer func() {
  6615. if r := recover(); r != nil {
  6616. if e, ok := r.(error); ok {
  6617. err = e
  6618. } else if s, ok := r.(string); ok {
  6619. err = fmt.Errorf("Unexpected panic: %s", s)
  6620. } else {
  6621. err = fmt.Errorf("Unexpected panic: %+v", r)
  6622. }
  6623. }
  6624. }()
  6625. buff := ctx.Buffer
  6626. version := buff.ReadUInt8()
  6627. if version > AllocationCodecVersion {
  6628. return fmt.Errorf("Invalid Version Unmarshaling RawAllocationOnlyData. Expected %d or less, got %d", AllocationCodecVersion, version)
  6629. }
  6630. a := buff.ReadFloat64() // read float64
  6631. target.CPUCoreUsageMax = a
  6632. b := buff.ReadFloat64() // read float64
  6633. target.RAMBytesUsageMax = b
  6634. // field version check
  6635. if uint8(23) <= version {
  6636. if buff.ReadUInt8() == uint8(0) {
  6637. target.GPUUsageMax = nil
  6638. } else {
  6639. c := buff.ReadFloat64() // read float64
  6640. target.GPUUsageMax = &c
  6641. }
  6642. } else {
  6643. target.GPUUsageMax = nil
  6644. }
  6645. return nil
  6646. }
  6647. //--------------------------------------------------------------------------
  6648. // SharedAsset
  6649. //--------------------------------------------------------------------------
  6650. // MarshalBinary serializes the internal properties of this SharedAsset instance
  6651. // into a byte array
  6652. func (target *SharedAsset) MarshalBinary() (data []byte, err error) {
  6653. ctx := &EncodingContext{
  6654. Buffer: util.NewBuffer(),
  6655. Table: nil,
  6656. }
  6657. e := target.MarshalBinaryWithContext(ctx)
  6658. if e != nil {
  6659. return nil, e
  6660. }
  6661. encBytes := ctx.Buffer.Bytes()
  6662. return encBytes, nil
  6663. }
  6664. // MarshalBinaryWithContext serializes the internal properties of this SharedAsset instance
  6665. // into a byte array leveraging a predefined context.
  6666. func (target *SharedAsset) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6667. // panics are recovered and propagated as errors
  6668. defer func() {
  6669. if r := recover(); r != nil {
  6670. if e, ok := r.(error); ok {
  6671. err = e
  6672. } else if s, ok := r.(string); ok {
  6673. err = fmt.Errorf("Unexpected panic: %s", s)
  6674. } else {
  6675. err = fmt.Errorf("Unexpected panic: %+v", r)
  6676. }
  6677. }
  6678. }()
  6679. buff := ctx.Buffer
  6680. buff.WriteUInt8(AssetsCodecVersion) // version
  6681. if target.Properties == nil {
  6682. buff.WriteUInt8(uint8(0)) // write nil byte
  6683. } else {
  6684. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6685. // --- [begin][write][struct](AssetProperties) ---
  6686. buff.WriteInt(0) // [compatibility, unused]
  6687. errA := target.Properties.MarshalBinaryWithContext(ctx)
  6688. if errA != nil {
  6689. return errA
  6690. }
  6691. // --- [end][write][struct](AssetProperties) ---
  6692. }
  6693. // --- [begin][write][alias](AssetLabels) ---
  6694. if map[string]string(target.Labels) == nil {
  6695. buff.WriteUInt8(uint8(0)) // write nil byte
  6696. } else {
  6697. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6698. // --- [begin][write][map](map[string]string) ---
  6699. buff.WriteInt(len(map[string]string(target.Labels))) // map length
  6700. for v, z := range map[string]string(target.Labels) {
  6701. if ctx.IsStringTable() {
  6702. a := ctx.Table.AddOrGet(v)
  6703. buff.WriteInt(a) // write table index
  6704. } else {
  6705. buff.WriteString(v) // write string
  6706. }
  6707. if ctx.IsStringTable() {
  6708. b := ctx.Table.AddOrGet(z)
  6709. buff.WriteInt(b) // write table index
  6710. } else {
  6711. buff.WriteString(z) // write string
  6712. }
  6713. }
  6714. // --- [end][write][map](map[string]string) ---
  6715. }
  6716. // --- [end][write][alias](AssetLabels) ---
  6717. // --- [begin][write][struct](Window) ---
  6718. buff.WriteInt(0) // [compatibility, unused]
  6719. errB := target.Window.MarshalBinaryWithContext(ctx)
  6720. if errB != nil {
  6721. return errB
  6722. }
  6723. // --- [end][write][struct](Window) ---
  6724. buff.WriteFloat64(target.Cost) // write float64
  6725. return nil
  6726. }
  6727. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6728. // the SharedAsset type
  6729. func (target *SharedAsset) UnmarshalBinary(data []byte) error {
  6730. var table []string
  6731. buff := util.NewBufferFromBytes(data)
  6732. // string table header validation
  6733. if isBinaryTag(data, BinaryTagStringTable) {
  6734. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6735. tl := buff.ReadInt() // table length
  6736. if tl > 0 {
  6737. table = make([]string, tl, tl)
  6738. for i := 0; i < tl; i++ {
  6739. table[i] = buff.ReadString()
  6740. }
  6741. }
  6742. }
  6743. ctx := &DecodingContext{
  6744. Buffer: buff,
  6745. Table: table,
  6746. }
  6747. err := target.UnmarshalBinaryWithContext(ctx)
  6748. if err != nil {
  6749. return err
  6750. }
  6751. return nil
  6752. }
  6753. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6754. // the SharedAsset type
  6755. func (target *SharedAsset) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6756. // panics are recovered and propagated as errors
  6757. defer func() {
  6758. if r := recover(); r != nil {
  6759. if e, ok := r.(error); ok {
  6760. err = e
  6761. } else if s, ok := r.(string); ok {
  6762. err = fmt.Errorf("Unexpected panic: %s", s)
  6763. } else {
  6764. err = fmt.Errorf("Unexpected panic: %+v", r)
  6765. }
  6766. }
  6767. }()
  6768. buff := ctx.Buffer
  6769. version := buff.ReadUInt8()
  6770. if version > AssetsCodecVersion {
  6771. return fmt.Errorf("Invalid Version Unmarshaling SharedAsset. Expected %d or less, got %d", AssetsCodecVersion, version)
  6772. }
  6773. if buff.ReadUInt8() == uint8(0) {
  6774. target.Properties = nil
  6775. } else {
  6776. // --- [begin][read][struct](AssetProperties) ---
  6777. a := &AssetProperties{}
  6778. buff.ReadInt() // [compatibility, unused]
  6779. errA := a.UnmarshalBinaryWithContext(ctx)
  6780. if errA != nil {
  6781. return errA
  6782. }
  6783. target.Properties = a
  6784. // --- [end][read][struct](AssetProperties) ---
  6785. }
  6786. // --- [begin][read][alias](AssetLabels) ---
  6787. var b map[string]string
  6788. if buff.ReadUInt8() == uint8(0) {
  6789. b = nil
  6790. } else {
  6791. // --- [begin][read][map](map[string]string) ---
  6792. d := buff.ReadInt() // map len
  6793. c := make(map[string]string, d)
  6794. for i := 0; i < d; i++ {
  6795. var v string
  6796. var f string
  6797. if ctx.IsStringTable() {
  6798. g := buff.ReadInt() // read string index
  6799. f = ctx.Table[g]
  6800. } else {
  6801. f = buff.ReadString() // read string
  6802. }
  6803. e := f
  6804. v = e
  6805. var z string
  6806. var k string
  6807. if ctx.IsStringTable() {
  6808. l := buff.ReadInt() // read string index
  6809. k = ctx.Table[l]
  6810. } else {
  6811. k = buff.ReadString() // read string
  6812. }
  6813. h := k
  6814. z = h
  6815. c[v] = z
  6816. }
  6817. b = c
  6818. // --- [end][read][map](map[string]string) ---
  6819. }
  6820. target.Labels = AssetLabels(b)
  6821. // --- [end][read][alias](AssetLabels) ---
  6822. // --- [begin][read][struct](Window) ---
  6823. m := &Window{}
  6824. buff.ReadInt() // [compatibility, unused]
  6825. errB := m.UnmarshalBinaryWithContext(ctx)
  6826. if errB != nil {
  6827. return errB
  6828. }
  6829. target.Window = *m
  6830. // --- [end][read][struct](Window) ---
  6831. n := buff.ReadFloat64() // read float64
  6832. target.Cost = n
  6833. return nil
  6834. }
  6835. //--------------------------------------------------------------------------
  6836. // Window
  6837. //--------------------------------------------------------------------------
  6838. // MarshalBinary serializes the internal properties of this Window instance
  6839. // into a byte array
  6840. func (target *Window) MarshalBinary() (data []byte, err error) {
  6841. ctx := &EncodingContext{
  6842. Buffer: util.NewBuffer(),
  6843. Table: nil,
  6844. }
  6845. e := target.MarshalBinaryWithContext(ctx)
  6846. if e != nil {
  6847. return nil, e
  6848. }
  6849. encBytes := ctx.Buffer.Bytes()
  6850. return encBytes, nil
  6851. }
  6852. // MarshalBinaryWithContext serializes the internal properties of this Window instance
  6853. // into a byte array leveraging a predefined context.
  6854. func (target *Window) MarshalBinaryWithContext(ctx *EncodingContext) (err error) {
  6855. // panics are recovered and propagated as errors
  6856. defer func() {
  6857. if r := recover(); r != nil {
  6858. if e, ok := r.(error); ok {
  6859. err = e
  6860. } else if s, ok := r.(string); ok {
  6861. err = fmt.Errorf("Unexpected panic: %s", s)
  6862. } else {
  6863. err = fmt.Errorf("Unexpected panic: %+v", r)
  6864. }
  6865. }
  6866. }()
  6867. buff := ctx.Buffer
  6868. buff.WriteUInt8(DefaultCodecVersion) // version
  6869. if target.start == nil {
  6870. buff.WriteUInt8(uint8(0)) // write nil byte
  6871. } else {
  6872. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6873. // --- [begin][write][reference](time.Time) ---
  6874. a, errA := target.start.MarshalBinary()
  6875. if errA != nil {
  6876. return errA
  6877. }
  6878. buff.WriteInt(len(a))
  6879. buff.WriteBytes(a)
  6880. // --- [end][write][reference](time.Time) ---
  6881. }
  6882. if target.end == nil {
  6883. buff.WriteUInt8(uint8(0)) // write nil byte
  6884. } else {
  6885. buff.WriteUInt8(uint8(1)) // write non-nil byte
  6886. // --- [begin][write][reference](time.Time) ---
  6887. b, errB := target.end.MarshalBinary()
  6888. if errB != nil {
  6889. return errB
  6890. }
  6891. buff.WriteInt(len(b))
  6892. buff.WriteBytes(b)
  6893. // --- [end][write][reference](time.Time) ---
  6894. }
  6895. return nil
  6896. }
  6897. // UnmarshalBinary uses the data passed byte array to set all the internal properties of
  6898. // the Window type
  6899. func (target *Window) UnmarshalBinary(data []byte) error {
  6900. var table []string
  6901. buff := util.NewBufferFromBytes(data)
  6902. // string table header validation
  6903. if isBinaryTag(data, BinaryTagStringTable) {
  6904. buff.ReadBytes(len(BinaryTagStringTable)) // strip tag length
  6905. tl := buff.ReadInt() // table length
  6906. if tl > 0 {
  6907. table = make([]string, tl, tl)
  6908. for i := 0; i < tl; i++ {
  6909. table[i] = buff.ReadString()
  6910. }
  6911. }
  6912. }
  6913. ctx := &DecodingContext{
  6914. Buffer: buff,
  6915. Table: table,
  6916. }
  6917. err := target.UnmarshalBinaryWithContext(ctx)
  6918. if err != nil {
  6919. return err
  6920. }
  6921. return nil
  6922. }
  6923. // UnmarshalBinaryWithContext uses the context containing a string table and binary buffer to set all the internal properties of
  6924. // the Window type
  6925. func (target *Window) UnmarshalBinaryWithContext(ctx *DecodingContext) (err error) {
  6926. // panics are recovered and propagated as errors
  6927. defer func() {
  6928. if r := recover(); r != nil {
  6929. if e, ok := r.(error); ok {
  6930. err = e
  6931. } else if s, ok := r.(string); ok {
  6932. err = fmt.Errorf("Unexpected panic: %s", s)
  6933. } else {
  6934. err = fmt.Errorf("Unexpected panic: %+v", r)
  6935. }
  6936. }
  6937. }()
  6938. buff := ctx.Buffer
  6939. version := buff.ReadUInt8()
  6940. if version > DefaultCodecVersion {
  6941. return fmt.Errorf("Invalid Version Unmarshaling Window. Expected %d or less, got %d", DefaultCodecVersion, version)
  6942. }
  6943. if buff.ReadUInt8() == uint8(0) {
  6944. target.start = nil
  6945. } else {
  6946. // --- [begin][read][reference](time.Time) ---
  6947. a := &time.Time{}
  6948. b := buff.ReadInt() // byte array length
  6949. c := buff.ReadBytes(b) // byte array
  6950. errA := a.UnmarshalBinary(c)
  6951. if errA != nil {
  6952. return errA
  6953. }
  6954. target.start = a
  6955. // --- [end][read][reference](time.Time) ---
  6956. }
  6957. if buff.ReadUInt8() == uint8(0) {
  6958. target.end = nil
  6959. } else {
  6960. // --- [begin][read][reference](time.Time) ---
  6961. d := &time.Time{}
  6962. e := buff.ReadInt() // byte array length
  6963. f := buff.ReadBytes(e) // byte array
  6964. errB := d.UnmarshalBinary(f)
  6965. if errB != nil {
  6966. return errB
  6967. }
  6968. target.end = d
  6969. // --- [end][read][reference](time.Time) ---
  6970. }
  6971. return nil
  6972. }