code: func (hm *HandshakeMessage) Marshal() []byte {
  	if hm == nil {
  		return []byte{}
  	}
  
  	fragLen := len(hm.body)
  	var data []byte
  
  	if hm.datagram {
  		data = make([]byte, handshakeHeaderLenDTLS+fragLen)
  	} else {
  		data = make([]byte, handshakeHeaderLenTLS+fragLen)
  	}
  	tmp := data
  	tmp = encodeUint(uint64(hm.msgType), 1, tmp)
  	tmp = encodeUint(uint64(hm.length), 3, tmp)
  	if hm.datagram {
  		tmp = encodeUint(uint64(hm.seq), 2, tmp)
  		tmp = encodeUint(uint64(hm.offset), 3, tmp)
  		tmp = encodeUint(uint64(fragLen), 3, tmp)
  	}
  	copy(tmp, hm.body)
  	return data
  }
docs: // Note: This could be done with the `syntax` module, using the simplified
  // syntax as discussed above.  However, since this is so simple, there's not
  // much benefit to doing so.
  // When datagram is set, we marshal this as a whole DTLS record.