macros: Use a nicer syntax when declaring attributes.

The previous version had a => required|optional|default token, this was
duplicating information for Option types and didn’t look very good.

This new version looks like a type, which can be either Required<_>,
Option<_> or Default<_>, and means the same thing.
This commit is contained in:
Emmanuel Gil Peyrot 2019-02-24 20:26:40 +01:00
commit bcd42a26e3
27 changed files with 162 additions and 137 deletions

View file

@ -11,20 +11,20 @@ generate_element!(
Open, "open", WEBSOCKET,
attributes: [
/// The JID of the entity opening this stream.
from: Option<Jid> = "from" => optional,
from: Option<Jid> = "from",
/// The JID of the entity receiving this stream opening.
to: Option<Jid> = "to" => optional,
to: Option<Jid> = "to",
/// The id of the stream, used for authentication challenges.
id: Option<String> = "id" => optional,
id: Option<String> = "id",
/// The XMPP version used during this stream.
version: Option<String> = "version" => optional,
version: Option<String> = "version",
/// The default human language for all subsequent stanzas, which will
/// be transmitted to other entities for better localisation.
xml_lang: Option<String> = "xml:lang" => optional,
xml_lang: Option<String> = "xml:lang",
]
);