code: func (kf *KeyFormat) KeyBytes(segments ...[]byte) ([]byte, error) {
  	key := make([]byte, kf.length)
  	n := copy(key, kf.prefix)
  	var offset int
  	for i, l := range kf.layout {
  		si := i + offset
  		if len(segments) <= si {
  			break
  		}
  		s := segments[si]
  		switch l {
  		case VariadicSegmentLength:
  			// Must be a final variadic element
  			key = append(key, s...)
  			n += len(s)
  		case DelimiterSegmentLength:
  			// ignore
  			offset--
  		default:
  			if len(s) != l {
  				return nil, fmt.Errorf("the segment '0x%X' provided to KeyFormat.KeyBytes() does not have required "+
  					"%d bytes required by layout for segment %d", s, l, i)
  			}
  			n += l
  			// Big endian so pad on left if not given the full width for this segment
  			copy(key[n-len(s):n], s)
  		}
  	}
  	return key[:n], nil
  }
docs: // Format the byte segments into the key format - will panic if the segment lengths do not match the layout.