opencost_codecs.go 187 KB

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