1 package bytewrite // import "vimagination.zapto.org/bytewrite" 2 3 var ( 4 // BigEndian implements the Endian interface. 5 BigEndian bigEndian 6 7 // LittleEndian implements the Endian interface. 8 LittleEndian littleEndian 9 _ Endian = BigEndian 10 _ Endian = LittleEndian 11 ) 12 13 // Endian represents the numerous methds available for easy endian conversion. 14 type Endian interface { 15 // Takes a slice of bytes and returns a float32 oriented according to the endianness. 16 Float32(b []byte) float32 17 18 // Takes a float32 and returns a slice of bytes, ordered according to the endianness. 19 PutFloat32(f float32) []byte 20 21 // Takes a slice of bytes and returns a float64 oriented according to the endianness. 22 Float64(b []byte) float64 23 24 // Takes a float64 and returns a slice of bytes, ordered according to the endianness. 25 PutFloat64(f float64) []byte 26 27 // Takes a slice of bytes and returns a uint16 oriented according to the endianness. 28 Uint16(b []byte) uint16 29 30 // Takes a uint16 and returns a slice of bytes, ordered according to the endianness. 31 PutUint16(v uint16) []byte 32 33 // Takes a slice of bytes and returns a uint32 oriented according to the endianness. 34 Uint32(b []byte) uint32 35 36 // Takes a uint32 and returns a slice of bytes, ordered according to the endianness. 37 PutUint32(v uint32) []byte 38 39 // Takes a slice of bytes and returns a uint64 oriented according to the endianness. 40 Uint64(b []byte) uint64 41 42 // Takes a uint64 and returns a slice of bytes, ordered according to the endianness. 43 PutUint64(v uint64) []byte 44 } 45