github.com/linuxboot/fiano@v1.2.0/pkg/intel/metadata/bg/svn_manifestcodegen.go (about) 1 // Copyright 2017-2021 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:build !manifestcodegen 6 // +build !manifestcodegen 7 8 // Code generated by "menifestcodegen". DO NOT EDIT. 9 // To reproduce: go run github.com/linuxboot/fiano/pkg/intel/metadata/common/manifestcodegen/cmd/manifestcodegen -package bg github.com/linuxboot/fiano/pkg/intel/metadata/bg 10 11 package bg 12 13 import ( 14 "encoding/binary" 15 "fmt" 16 "io" 17 "strings" 18 19 "github.com/linuxboot/fiano/pkg/intel/metadata/common/pretty" 20 ) 21 22 var ( 23 // Just to avoid errors in "import" above in case if it wasn't used below 24 _ = binary.LittleEndian 25 _ = (fmt.Stringer)(nil) 26 _ = (io.Reader)(nil) 27 _ = pretty.Header 28 _ = strings.Join 29 ) 30 31 // PrettyString returns the bits of the flags in an easy-to-read format. 32 func (v SVN) PrettyString(depth uint, withHeader bool, opts ...pretty.Option) string { 33 var lines []string 34 if withHeader { 35 lines = append(lines, pretty.Header(depth, "SVN", v)) 36 } 37 lines = append(lines, pretty.SubValue(depth+1, "SVN", "", v.SVN(), opts...)...) 38 return strings.Join(lines, "\n") 39 } 40 41 // TotalSize returns the total size measured through binary.Size. 42 func (v SVN) TotalSize() uint64 { 43 return uint64(binary.Size(v)) 44 } 45 46 // WriteTo writes the SVN into 'w' in binary format. 47 func (v SVN) WriteTo(w io.Writer) (int64, error) { 48 return int64(v.TotalSize()), binary.Write(w, binary.LittleEndian, v) 49 } 50 51 // ReadFrom reads the SVN from 'r' in binary format. 52 func (v SVN) ReadFrom(r io.Reader) (int64, error) { 53 return int64(v.TotalSize()), binary.Read(r, binary.LittleEndian, v) 54 }