aws_iot_device_sdk/
tunneling.rs1use crate::common::*;
2
3const API_CHANGED: &str = "notify";
4
5pub fn match_topic(topic: &str) -> Result<(), Error> {
16 is_valid_mqtt_topic(topic)?;
18
19 let s = is_valid_prefix(topic, AWS_THINGS_PREFIX)?;
20
21 let mid = s.find('/').ok_or(Error::FAIL);
22 let (thing_name, mut s) = s.split_at(mid?);
23 is_valid_thing_name(thing_name)?;
24
25 s = is_valid_bridge(s, TUNNELS_API_BRIDGE)?;
26
27 if s == API_CHANGED {
28 return Ok(());
29 }
30 Err(Error::NoMatch)
31}
32
33#[cfg(test)]
34mod tests {
35 use crate::tunneling;
36 #[test]
37 fn tunnels_match_topic() {
38 let tunnels = tunneling::match_topic("$aws/things/chloe/tunnels/notify");
39 assert_eq!(tunnels, Ok(()));
40 }
41}