add validation to s9pks

This commit is contained in:
Aiden McClelland
2022-02-07 15:27:07 -07:00
committed by Aiden McClelland
parent 2c17038b19
commit 08770567d2
11 changed files with 321 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
use std::borrow::{Borrow, Cow};
use std::fmt::Debug;
use std::str::FromStr;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
@@ -158,6 +159,12 @@ impl<S: AsRef<str>> ImageId<S> {
)
}
}
impl FromStr for ImageId {
type Err = InvalidId;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(ImageId(Id::try_from(s.to_owned())?))
}
}
impl<'de, S> Deserialize<'de> for ImageId<S>
where
S: AsRef<str>,