opencost_codecs.go 195 KB

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