opencost_codecs.go 230 KB

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