mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
parsers/ssma: Use an enum for @semantics.
This one comes from RFC5588.
This commit is contained in:
parent
b30572612b
commit
8ddd488b7f
1 changed files with 29 additions and 4 deletions
|
@ -39,12 +39,35 @@ generate_element!(
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
generate_attribute!(
|
||||||
|
/// From RFC5888, the list of allowed semantics.
|
||||||
|
Semantics, "semantics", {
|
||||||
|
/// Lip Synchronization, defined in RFC5888.
|
||||||
|
Ls => "LS",
|
||||||
|
|
||||||
|
/// Flow Identification, defined in RFC5888.
|
||||||
|
Fid => "FID",
|
||||||
|
|
||||||
|
/// Single Reservation Flow, defined in RFC3524.
|
||||||
|
Srf => "SRF",
|
||||||
|
|
||||||
|
/// Alternative Network Address Types, defined in RFC4091.
|
||||||
|
Anat => "ANAT",
|
||||||
|
|
||||||
|
/// Forward Error Correction, defined in RFC4756.
|
||||||
|
Fec => "FEC",
|
||||||
|
|
||||||
|
/// Decoding Dependency, defined in RFC5583.
|
||||||
|
Ddp => "DDP",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Element grouping multiple ssrc.
|
/// Element grouping multiple ssrc.
|
||||||
Group, "ssrc-group", JINGLE_SSMA,
|
Group, "ssrc-group", JINGLE_SSMA,
|
||||||
attributes: [
|
attributes: [
|
||||||
/// The semantics of this group.
|
/// The semantics of this group.
|
||||||
semantics: Required<String> = "semantics",
|
semantics: Required<Semantics> = "semantics",
|
||||||
],
|
],
|
||||||
children: [
|
children: [
|
||||||
/// The various ssrc concerned by this group.
|
/// The various ssrc concerned by this group.
|
||||||
|
@ -63,7 +86,8 @@ mod tests {
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
assert_size!(Source, 16);
|
assert_size!(Source, 16);
|
||||||
assert_size!(Parameter, 24);
|
assert_size!(Parameter, 24);
|
||||||
assert_size!(Group, 24);
|
assert_size!(Semantics, 1);
|
||||||
|
assert_size!(Group, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "64")]
|
#[cfg(target_pointer_width = "64")]
|
||||||
|
@ -71,7 +95,8 @@ mod tests {
|
||||||
fn test_size() {
|
fn test_size() {
|
||||||
assert_size!(Source, 32);
|
assert_size!(Source, 32);
|
||||||
assert_size!(Parameter, 48);
|
assert_size!(Parameter, 48);
|
||||||
assert_size!(Group, 48);
|
assert_size!(Semantics, 1);
|
||||||
|
assert_size!(Group, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -107,7 +132,7 @@ mod tests {
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut group = Group::try_from(elem).unwrap();
|
let mut group = Group::try_from(elem).unwrap();
|
||||||
assert_eq!(group.semantics, "FID");
|
assert_eq!(group.semantics, Semantics::Fid);
|
||||||
assert_eq!(group.sources.len(), 2);
|
assert_eq!(group.sources.len(), 2);
|
||||||
let source = group.sources.pop().unwrap();
|
let source = group.sources.pop().unwrap();
|
||||||
assert_eq!(source.id, 386328120);
|
assert_eq!(source.id, 386328120);
|
||||||
|
|
Loading…
Reference in a new issue