Add FromStr impl for ScabbardStorage
To convert from strings passed into clap there needs to be a function to
convert a string to a ScabbardStorage enum. This commit adds that function.
// limitations under the License.
use std::fmt::Display;
+use std::str::FromStr;
#[derive(Debug, Copy, Clone)]
pub enum ScabbardStorage {
@@ -33,3 +34,14 @@ impl Display for ScabbardStorageError {
}
}
}
+
+impl FromStr for ScabbardStorage {
+ type Err = ScabbardStorageError;
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ match s {
+ "database" => Ok(Self::Database),
+ "lmdb" => Ok(Self::Lmdb),
+ _ => Err(ScabbardStorageError::ParseError(s.to_string())),
+ }
+ }
+}
