pub mod backoff_algo;
pub mod common;
pub mod defender;
pub mod jobs;
pub mod shadow;
pub mod tunneling;
pub use common::*;
#[derive(Debug, PartialEq)]
pub enum TopicType {
Other = 0,
NamedShadow,
Shadow,
Jobs,
Defender,
Tunneling,
}
pub fn match_topic_type<'a>(topic: &'a str) -> Result<TopicType, Error> {
is_valid_mqtt_topic(topic)?;
let s = is_valid_prefix(topic, AWS_THINGS_PREFIX)?;
let mid = s.find('/').ok_or(Error::NoMatch);
let (thing_name, s) = s.split_at(mid?);
is_valid_thing_name(thing_name)?;
if s.starts_with(NAMED_SHADOW_API_BRIDGE) { Ok(TopicType::NamedShadow) }
else if s.starts_with(SHADOW_API_BRIDGE) { Ok(TopicType::Shadow) }
else if s.starts_with(JOBS_API_BRIDGE) { Ok(TopicType::Jobs) }
else if s.starts_with(DEFENDER_API_BRIDGE) { Ok(TopicType::Defender) }
else if s.starts_with(TUNNELS_API_BRIDGE) { Ok(TopicType::Tunneling) }
else { Err(Error::NoMatch) }
}