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:
parent
f2c3f45a6f
commit
bcd42a26e3
27 changed files with 162 additions and 137 deletions
12
src/ibb.rs
12
src/ibb.rs
|
|
@ -30,13 +30,13 @@ generate_element!(
|
|||
Open, "open", IBB,
|
||||
attributes: [
|
||||
/// Maximum size in bytes for each chunk.
|
||||
block_size: u16 = "block-size" => required,
|
||||
block_size: Required<u16> = "block-size",
|
||||
|
||||
/// The identifier to be used to create a stream.
|
||||
sid: StreamId = "sid" => required,
|
||||
sid: Required<StreamId> = "sid",
|
||||
|
||||
/// Which stanza type to use to exchange data.
|
||||
stanza: Stanza = "stanza" => default,
|
||||
stanza: Default<Stanza> = "stanza",
|
||||
]);
|
||||
|
||||
impl IqSetPayload for Open {}
|
||||
|
|
@ -46,10 +46,10 @@ generate_element!(
|
|||
Data, "data", IBB,
|
||||
attributes: [
|
||||
/// Sequence number of this chunk, must wraparound after 65535.
|
||||
seq: u16 = "seq" => required,
|
||||
seq: Required<u16> = "seq",
|
||||
|
||||
/// The identifier of the stream on which data is being exchanged.
|
||||
sid: StreamId = "sid" => required
|
||||
sid: Required<StreamId> = "sid"
|
||||
],
|
||||
text: (
|
||||
/// Vector of bytes to be exchanged.
|
||||
|
|
@ -64,7 +64,7 @@ generate_element!(
|
|||
Close, "close", IBB,
|
||||
attributes: [
|
||||
/// The identifier of the stream to be closed.
|
||||
sid: StreamId = "sid" => required,
|
||||
sid: Required<StreamId> = "sid",
|
||||
]);
|
||||
|
||||
impl IqSetPayload for Close {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue