github.com/linuxboot/fiano@v1.2.0/pkg/intel/metadata/bg/structure.go (about) 1 // Copyright 2017-2023 the LinuxBoot Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:generate manifestcodegen 6 7 package bg 8 9 import ( 10 "encoding/binary" 11 "io" 12 13 "github.com/linuxboot/fiano/pkg/intel/metadata/common/pretty" 14 ) 15 16 var ( 17 binaryOrder = binary.LittleEndian 18 ) 19 20 type StructInfo struct { 21 ID StructureID `json:"StructInfoID"` 22 Version uint8 `json:"StructInfoVersion"` 23 } 24 25 func (s StructInfo) StructInfo() StructInfo { 26 return s 27 } 28 29 type StructureID [8]byte 30 31 func (s StructureID) String() string { 32 return string(s[:]) 33 } 34 35 type Structure interface { 36 io.ReaderFrom 37 io.WriterTo 38 TotalSize() uint64 39 PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string 40 } 41 42 type Element interface { 43 Structure 44 ReadDataFrom(r io.Reader) (int64, error) 45 GetStructInfo() StructInfo 46 SetStructInfo(StructInfo) 47 } 48 49 type ElementsContainer interface { 50 Structure 51 GetFieldByStructID(structID string) interface{} 52 } 53 54 type Manifest interface { 55 Structure 56 }