pub const PROTOCOL_CONTROL: &str = "/ganglion/control/1.0";
pub const PROTOCOL_TOOL: &str = "/ganglion/tool/1.0";
pub const PROTOCOL_BULK: &str = "/ganglion/bulk/1.0";
pub const ALL_PROTOCOLS: &[&str] = &[PROTOCOL_CONTROL, PROTOCOL_TOOL, PROTOCOL_BULK];
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct ProtocolId(String);
impl ProtocolId {
pub fn new(id: impl Into<String>) -> Self {
Self(id.into())
}
pub fn as_str(&self) -> &str {
&self.0
}
pub fn control() -> Self {
Self(PROTOCOL_CONTROL.into())
}
pub fn tool() -> Self {
Self(PROTOCOL_TOOL.into())
}
pub fn bulk() -> Self {
Self(PROTOCOL_BULK.into())
}
}
impl std::fmt::Display for ProtocolId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}