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

@ -55,23 +55,23 @@ generate_element!(
Candidate, "candidate", JINGLE_S5B,
attributes: [
/// The identifier for this candidate.
cid: CandidateId = "cid" => required,
cid: Required<CandidateId> = "cid",
/// The host to connect to.
host: IpAddr = "host" => required,
host: Required<IpAddr> = "host",
/// The JID to request at the given end.
jid: Jid = "jid" => required,
jid: Required<Jid> = "jid",
/// The port to connect to.
port: Option<u16> = "port" => optional,
port: Option<u16> = "port",
/// The priority of this candidate, computed using this formula:
/// priority = (2^16)*(type preference) + (local preference)
priority: u32 = "priority" => required,
priority: Required<u32> = "priority",
/// The type of the connection being proposed by this candidate.
type_: Type = "type" => default,
type_: Default<Type> = "type",
]
);