diff --git a/src/tsig/tsig_algorithm.rs b/src/tsig/tsig_algorithm.rs new file mode 100644 index 00000000..5bdf4f0e --- /dev/null +++ b/src/tsig/tsig_algorithm.rs @@ -0,0 +1,25 @@ + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum TsigAlgorithm { + HmacSha1, + HmacSha256, +} + +impl From for String { + fn from(alg: TsigAlgorithm) -> String { + match alg { + TsigAlgorithm::HmacSha1 => "hmac-sha1".to_string(), + TsigAlgorithm::HmacSha256 => "hmac-sha256".to_string(), + } + } +} + +impl From for TsigAlgorithm { + fn from(name: String) -> TsigAlgorithm { + match name { + name if name == "hmac-sha1" => TsigAlgorithm::HmacSha1, + name if name == "hmac-sha256" => TsigAlgorithm::HmacSha256, + _ => panic!("Invalid TsigAlgorithm"), + } + } +} \ No newline at end of file