//! GENERATED FILE — DO NOT EDIT. //! Source: packages/core-contracts/schemas/*.schema.json (run `pnpm gen`) #![allow(clippy::all, rustdoc::all, dead_code, unused_imports)] #![allow(clippy::needless_lifetimes)] #![allow(clippy::match_single_binding)] #![allow(clippy::clone_on_copy)] #[doc = "`KeyId`"] #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] #[serde(transparent)] pub struct KeyId(::std::string::String); impl ::std::ops::Deref for KeyId { type Target = ::std::string::String; fn deref(&self) -> &::std::string::String { &self.0 } } impl ::std::convert::From for ::std::string::String { fn from(value: KeyId) -> Self { value.0 } } impl ::std::str::FromStr for KeyId { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(|| { ::regress::Regex::new("^[a-z0-9][a-z0-9-]{2,63}$").unwrap() }); if PATTERN.find(value).is_none() { return Err("doesn't match pattern \"^[a-z0-9][a-z0-9-]{2,63}$\"".into()); } Ok(Self(value.to_string())) } } impl ::std::convert::TryFrom<&str> for KeyId { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for KeyId { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } impl<'de> ::serde::Deserialize<'de> for KeyId { fn deserialize(deserializer: D) -> ::std::result::Result where D: ::serde::Deserializer<'de>, { ::std::string::String::deserialize(deserializer)? .parse() .map_err(|e: self::error::ConversionError| { ::custom(e.to_string()) }) } } #[doc = "`ListedKey`"] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(deny_unknown_fields)] pub struct ListedKey { #[serde(rename = "keyId")] pub key_id: KeyId, #[serde(rename = "notAfter")] pub not_after: Timestamp, #[serde(rename = "notBefore")] pub not_before: Timestamp, #[doc = "The raw 32-byte Ed25519 public key, base64."] #[serde(rename = "publicKey")] pub public_key: ListedKeyPublicKey, pub role: ListedKeyRole, pub status: ListedKeyStatus, } #[doc = "The raw 32-byte Ed25519 public key, base64."] #[derive(:: serde :: Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] #[serde(transparent)] pub struct ListedKeyPublicKey(::std::string::String); impl ::std::ops::Deref for ListedKeyPublicKey { type Target = ::std::string::String; fn deref(&self) -> &::std::string::String { &self.0 } } impl ::std::convert::From for ::std::string::String { fn from(value: ListedKeyPublicKey) -> Self { value.0 } } impl ::std::str::FromStr for ListedKeyPublicKey { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(|| ::regress::Regex::new("^[A-Za-z0-9+/]{43}=$").unwrap()); if PATTERN.find(value).is_none() { return Err("doesn't match pattern \"^[A-Za-z0-9+/]{43}=$\"".into()); } Ok(Self(value.to_string())) } } impl ::std::convert::TryFrom<&str> for ListedKeyPublicKey { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for ListedKeyPublicKey { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } impl<'de> ::serde::Deserialize<'de> for ListedKeyPublicKey { fn deserialize(deserializer: D) -> ::std::result::Result where D: ::serde::Deserializer<'de>, { ::std::string::String::deserialize(deserializer)? .parse() .map_err(|e: self::error::ConversionError| { ::custom(e.to_string()) }) } } #[doc = "`ListedKeyRole`"] #[derive( :: serde :: Deserialize, :: serde :: Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, )] pub enum ListedKeyRole { #[serde(rename = "release")] Release, #[serde(rename = "yank")] Yank, } impl ::std::fmt::Display for ListedKeyRole { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Self::Release => f.write_str("release"), Self::Yank => f.write_str("yank"), } } } impl ::std::str::FromStr for ListedKeyRole { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { match value { "release" => Ok(Self::Release), "yank" => Ok(Self::Yank), _ => Err("invalid value".into()), } } } impl ::std::convert::TryFrom<&str> for ListedKeyRole { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for ListedKeyRole { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } #[doc = "`ListedKeyStatus`"] #[derive( :: serde :: Deserialize, :: serde :: Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, )] pub enum ListedKeyStatus { #[serde(rename = "active")] Active, #[serde(rename = "retiring")] Retiring, #[serde(rename = "revoked")] Revoked, } impl ::std::fmt::Display for ListedKeyStatus { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Self::Active => f.write_str("active"), Self::Retiring => f.write_str("retiring"), Self::Revoked => f.write_str("revoked"), } } } impl ::std::str::FromStr for ListedKeyStatus { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { match value { "active" => Ok(Self::Active), "retiring" => Ok(Self::Retiring), "revoked" => Ok(Self::Revoked), _ => Err("invalid value".into()), } } } impl ::std::convert::TryFrom<&str> for ListedKeyStatus { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for ListedKeyStatus { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } #[doc = "cloudhal.release-keys@1 (RFC-0046 §9): the root-signed list of Cloudhal's release and yank keys, published as keys.json at https://cloudhal.dev/.well-known/cloudhal/keys.json next to keys.json.sig (a raw 64-byte Ed25519 signature by the offline root over the exact bytes). A consumer uses it only to reduce trust in the keys it pins: revoke, mark retiring, narrow a validity window; it never adds a key. Canonical bytes as for the release statement."] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(deny_unknown_fields)] pub struct ReleaseKeys { #[doc = "At most 13 months after issuedAt; a consumer refuses an expired list."] pub expires: Timestamp, pub format: ReleaseKeysFormat, #[serde(rename = "issuedAt")] pub issued_at: Timestamp, pub keys: ::std::vec::Vec, #[serde(rename = "schemaVersion")] pub schema_version: SchemaVersion, pub signing: ReleaseKeysSigning, } #[doc = "`ReleaseKeysFormat`"] #[derive( :: serde :: Deserialize, :: serde :: Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, )] pub enum ReleaseKeysFormat { #[serde(rename = "cloudhal.release-keys@1")] CloudhalReleaseKeys1, } impl ::std::fmt::Display for ReleaseKeysFormat { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Self::CloudhalReleaseKeys1 => f.write_str("cloudhal.release-keys@1"), } } } impl ::std::str::FromStr for ReleaseKeysFormat { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { match value { "cloudhal.release-keys@1" => Ok(Self::CloudhalReleaseKeys1), _ => Err("invalid value".into()), } } } impl ::std::convert::TryFrom<&str> for ReleaseKeysFormat { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for ReleaseKeysFormat { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } #[doc = "`ReleaseKeysSigning`"] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(deny_unknown_fields)] pub struct ReleaseKeysSigning { pub algorithm: ReleaseKeysSigningAlgorithm, #[doc = "The root key that signed this list."] #[serde(rename = "keyId")] pub key_id: KeyId, pub signature: ReleaseKeysSigningSignature, } #[doc = "`ReleaseKeysSigningAlgorithm`"] #[derive( :: serde :: Deserialize, :: serde :: Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, )] pub enum ReleaseKeysSigningAlgorithm { Ed25519, } impl ::std::fmt::Display for ReleaseKeysSigningAlgorithm { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Self::Ed25519 => f.write_str("Ed25519"), } } } impl ::std::str::FromStr for ReleaseKeysSigningAlgorithm { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { match value { "Ed25519" => Ok(Self::Ed25519), _ => Err("invalid value".into()), } } } impl ::std::convert::TryFrom<&str> for ReleaseKeysSigningAlgorithm { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for ReleaseKeysSigningAlgorithm { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } #[doc = "`ReleaseKeysSigningSignature`"] #[derive( :: serde :: Deserialize, :: serde :: Serialize, Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, )] pub enum ReleaseKeysSigningSignature { #[serde(rename = "keys.json.sig")] KeysJsonSig, } impl ::std::fmt::Display for ReleaseKeysSigningSignature { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match *self { Self::KeysJsonSig => f.write_str("keys.json.sig"), } } } impl ::std::str::FromStr for ReleaseKeysSigningSignature { type Err = self::error::ConversionError; fn from_str(value: &str) -> ::std::result::Result { match value { "keys.json.sig" => Ok(Self::KeysJsonSig), _ => Err("invalid value".into()), } } } impl ::std::convert::TryFrom<&str> for ReleaseKeysSigningSignature { type Error = self::error::ConversionError; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom<::std::string::String> for ReleaseKeysSigningSignature { type Error = self::error::ConversionError; fn try_from( value: ::std::string::String, ) -> ::std::result::Result { value.parse() } } #[doc = "Version of this contract. Readers reject unknown versions; migrations move documents forward one version at a time."] #[derive(:: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(transparent)] pub struct SchemaVersion(i64); impl ::std::ops::Deref for SchemaVersion { type Target = i64; fn deref(&self) -> &i64 { &self.0 } } impl ::std::convert::From for i64 { fn from(value: SchemaVersion) -> Self { value.0 } } impl ::std::convert::TryFrom for SchemaVersion { type Error = self::error::ConversionError; fn try_from(value: i64) -> ::std::result::Result { if ![1_i64].contains(&value) { Err("invalid value".into()) } else { Ok(Self(value)) } } } impl<'de> ::serde::Deserialize<'de> for SchemaVersion { fn deserialize(deserializer: D) -> ::std::result::Result where D: ::serde::Deserializer<'de>, { Self::try_from(::deserialize(deserializer)?) .map_err(|e| ::custom(e.to_string())) } } #[doc = "RFC 3339 / ISO 8601 instant in UTC."] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug, PartialEq)] #[serde(transparent)] pub struct Timestamp(pub ::chrono::DateTime<::chrono::offset::Utc>); impl ::std::ops::Deref for Timestamp { type Target = ::chrono::DateTime<::chrono::offset::Utc>; fn deref(&self) -> &::chrono::DateTime<::chrono::offset::Utc> { &self.0 } } impl ::std::convert::From for ::chrono::DateTime<::chrono::offset::Utc> { fn from(value: Timestamp) -> Self { value.0 } } impl ::std::convert::From<::chrono::DateTime<::chrono::offset::Utc>> for Timestamp { fn from(value: ::chrono::DateTime<::chrono::offset::Utc>) -> Self { Self(value) } } impl ::std::fmt::Display for Timestamp { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { self.0.fmt(f) } } impl ::std::str::FromStr for Timestamp { type Err = <::chrono::DateTime<::chrono::offset::Utc> as ::std::str::FromStr>::Err; fn from_str(value: &str) -> ::std::result::Result { Ok(Self(value.parse()?)) } } impl ::std::convert::TryFrom<&str> for Timestamp { type Error = <::chrono::DateTime<::chrono::offset::Utc> as ::std::str::FromStr>::Err; fn try_from(value: &str) -> ::std::result::Result { value.parse() } } impl ::std::convert::TryFrom for Timestamp { type Error = <::chrono::DateTime<::chrono::offset::Utc> as ::std::str::FromStr>::Err; fn try_from(value: String) -> ::std::result::Result { value.parse() } } #[doc = " Error types."] pub mod error { #[doc = r" Error from a `TryFrom` or `FromStr` implementation."] pub struct ConversionError(::std::borrow::Cow<'static, str>); impl ::std::error::Error for ConversionError {} impl ::std::fmt::Display for ConversionError { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { ::std::fmt::Display::fmt(&self.0, f) } } impl ::std::fmt::Debug for ConversionError { fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> { ::std::fmt::Debug::fmt(&self.0, f) } } impl From<&'static str> for ConversionError { fn from(value: &'static str) -> Self { Self(value.into()) } } impl From for ConversionError { fn from(value: String) -> Self { Self(value.into()) } } }