1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
package efivarfs
import (
"bytes"
"io"
)
// This package contains misc types we might promote to something more sane at a later point.
// Currently only used internally to serialize/deserialize values we need to native Go types.
// TODO: Move this to something better?
//
// I don't think we'll be using this to actually write stuff
type efibool bool
func (s *efibool) Unmarshal(b *bytes.Buffer) error {
n, err := b.ReadByte()
if err != nil {
return err
}
*s = n == 1
return nil
}
type efibytes bytes.Buffer
func (e efibytes) Marshal(b *bytes.Buffer) {
if _, err := io.Copy(b, (*bytes.Buffer)(&e)); err != nil {
return
}
}
func (e efibytes) Bytes() []byte {
var b bytes.Buffer
e.Marshal(&b)
return b.Bytes()
}
|