aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2019-05-15 04:57:51 +0200
committerDaniel Schadt <kingdread@gmx.de>2019-05-15 04:57:51 +0200
commitcbd84c3262b10ebff6d5508370287be05b2bfb3b (patch)
treead6d7f1f2706d2cbf46d07ad1a5edbad71887791 /src/event.rs
parent32bf6396a65e9aa83f746b964ed822fd5f839773 (diff)
downloadevtclib-cbd84c3262b10ebff6d5508370287be05b2bfb3b.tar.gz
evtclib-cbd84c3262b10ebff6d5508370287be05b2bfb3b.tar.bz2
evtclib-cbd84c3262b10ebff6d5508370287be05b2bfb3b.zip
rewrite parsing support for guild
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/event.rs b/src/event.rs
index ce4f815..5800414 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -326,11 +326,18 @@ fn get_api_guild_string(bytes: &[u8; 16]) -> Option<String> {
if bytes == &[0; 16] {
return None;
}
- let result = format!(
- "{:02X}{:02X}{:02X}{:02X}-{:02X}{:02X}-{:02X}{:02X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}",
- bytes[4], bytes[5], bytes[6], bytes[7], bytes[2], bytes[3], bytes[0], bytes[1], bytes[11],
- bytes[10], bytes[9], bytes[8], bytes[15], bytes[14], bytes[13], bytes[12]
- );
+ static PACKS: &[&[usize]] = &[
+ &[4, 5, 6, 7],
+ &[2, 3],
+ &[0, 1],
+ &[11, 10],
+ &[9, 8, 15, 14, 13, 12],
+ ];
+ let result = PACKS
+ .iter()
+ .map(|p| p.iter().map(|i| format!("{:02X}", bytes[*i])).collect())
+ .collect::<Vec<String>>()
+ .join("-");
Some(result)
}