func (fh *FixedHeader) WriteTo(w io.Writer) (int, error) {

	var b byte
	b = byte(fh.PacketType) << 4
	if fh.Dup {
		b |= 0x80
	}
	b |= fh.QoS << 1
	if fh.Retain {
		b |= 0x01
	}

	if fh.Length < 0x80 {
		return w.Write([]byte{b, byte(fh.Length)})
	} else if fh.Length < 0x4000 {
		return w.Write([]byte{b, byte(fh.Length&127) | 0x80, byte(fh.Length >> 7)})
	} else if fh.Length < 0x200000 {
		return w.Write([]byte{b, byte(fh.Length&127) | 0x80, byte((fh.Length>>7)&127) | 0x80, byte(fh.Length >> 14)})
	}
	return 0, errMessageTooLong
}
// WriteTo writes the FixedHeader to an io.Writer.
WriteTo writes the FixedHeader to an io.Writer.
// WriteTo writes the FixedHeader to an io . Writer .
func (fh *FixedHeader) WriteTo(w io.Writer) (int, error) {
	var b byte
	b = byte(fh.PacketType) << 4
	if fh.Dup {
		b |= 0x80
	}
	b |= fh.QoS << 1
	if fh.Retain {
		b |= 0x01
	}
	if fh.Length < 0x80 {
		return w.Write([]byte{b, byte(fh.Length)})
	} else if fh.Length < 0x4000 {
		return w.Write([]byte{b, byte(fh.Length&127) | 0x80, byte(fh.Length >> 7)})
	} else if fh.Length < 0x200000 {
		return w.Write([]byte{b, byte(fh.Length&127) | 0x80, byte((fh.Length>>7)&127) | 0x80, byte(fh.Length >> 14)})
	}
	return 0, errMessageTooLong
}
func ( fh * FixedHeader ) WriteTo ( w io . Writer ) ( int , error ) { var b byte b = byte ( fh . PacketType ) << 4 if fh . Dup { b |= 0x80 } b |= fh . QoS << 1 if fh . Retain { b |= 0x01 } if fh . Length < 0x80 { return w . Write ( [ ] byte { b , byte ( fh . Length ) } ) } else if fh . Length < 0x4000 { return w . Write ( [ ] byte { b , byte ( fh . Length & 127 ) | 0x80 , byte ( fh . Length >> 7 ) } ) } else if fh . Length < 0x200000 { return w . Write ( [ ] byte { b , byte ( fh . Length & 127 ) | 0x80 , byte ( ( fh . Length >> 7 ) & 127 ) | 0x80 , byte ( fh . Length >> 14 ) } ) } return 0 , errMessageTooLong }
WriteTo writes the FixedHeader to an io.Writer.
WriteTo writes the FixedHeader to an io . Writer .