'Convert me into a wire-encoded string.
@return: a C{bytes} encoded according to the rules described in the
module docstring.'

def serialize(self):

    i = sorted(iteritems(self))
    L = []
    w = L.append
    for (k, v) in i:
        if (type(k) == unicode):
            raise TypeError(('Unicode    key    not    allowed:    %r' % k))
        if (type(v) == unicode):
            raise TypeError(('Unicode    value    for    key    %r    not    allowed:    %r' % (k, v)))
        if (len(k) > MAX_KEY_LENGTH):
            raise TooLong(True, True, k, None)
        if (len(v) > MAX_VALUE_LENGTH):
            raise TooLong(False, True, v, k)
        for kv in (k, v):
            w(pack('!H', len(kv)))
            w(kv)
    w(pack('!H', 0))
    return ''.join(L)
