opencost_codecs.go 205 KB

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