opencost_codecs.go 186 KB

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