diff --git a/Cargo.lock b/Cargo.lock index 82c12b0..a5ca90d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,7 +125,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -136,7 +136,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -326,7 +326,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -510,7 +510,7 @@ dependencies = [ "quote", "serde", "serde_tokenstream", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -587,7 +587,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.46", + "syn 2.0.48", "uuid", ] @@ -615,7 +615,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.46", + "syn 2.0.48", "uuid", "wasm-bindgen-test", ] @@ -723,7 +723,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -1373,7 +1373,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -1439,7 +1439,7 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "syn 2.0.46", + "syn 2.0.48", "thiserror", "typify", "unicode-ident", @@ -1458,7 +1458,7 @@ dependencies = [ "serde_json", "serde_tokenstream", "serde_yaml", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -1811,22 +1811,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.195" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -1842,9 +1842,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.109" +version = "1.0.111" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0652c533506ad7a2e353cce269330d6afd8bdfb6d75e0ace5b35aacbd7b9e9" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" dependencies = [ "itoa", "ryu", @@ -1879,7 +1879,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -2051,9 +2051,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.46" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -2122,22 +2122,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.51" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f11c217e1416d6f036b870f14e0413d480dbf28edbee1f877abaf0206af43bb7" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.51" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01742297787513b79cf8e29d1056ede1313e2420b7b3b15d0a768b4921f549df" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -2209,7 +2209,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] @@ -2359,7 +2359,7 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "typify" version = "0.0.15" -source = "git+https://github.com/oxidecomputer/typify#7ceddf6644356819d1c829deb7a160197c4d0493" +source = "git+https://github.com/oxidecomputer/typify#1d8e828f29636613f0d29349f9ae0e41a546b454" dependencies = [ "typify-impl", "typify-macro", @@ -2368,7 +2368,7 @@ dependencies = [ [[package]] name = "typify-impl" version = "0.0.15" -source = "git+https://github.com/oxidecomputer/typify#7ceddf6644356819d1c829deb7a160197c4d0493" +source = "git+https://github.com/oxidecomputer/typify#1d8e828f29636613f0d29349f9ae0e41a546b454" dependencies = [ "heck", "log", @@ -2377,7 +2377,7 @@ dependencies = [ "regress", "schemars", "serde_json", - "syn 2.0.46", + "syn 2.0.48", "thiserror", "unicode-ident", ] @@ -2385,7 +2385,7 @@ dependencies = [ [[package]] name = "typify-macro" version = "0.0.15" -source = "git+https://github.com/oxidecomputer/typify#7ceddf6644356819d1c829deb7a160197c4d0493" +source = "git+https://github.com/oxidecomputer/typify#1d8e828f29636613f0d29349f9ae0e41a546b454" dependencies = [ "proc-macro2", "quote", @@ -2393,7 +2393,7 @@ dependencies = [ "serde", "serde_json", "serde_tokenstream", - "syn 2.0.46", + "syn 2.0.48", "typify-impl", ] @@ -2546,7 +2546,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", "wasm-bindgen-shared", ] @@ -2580,7 +2580,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2613,7 +2613,7 @@ checksum = "794645f5408c9a039fd09f4d113cdfb2e7eba5ff1956b07bcf701cf4b394fe89" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.48", ] [[package]] diff --git a/progenitor-impl/tests/output/src/buildomat_builder.rs b/progenitor-impl/tests/output/src/buildomat_builder.rs index 48b685f..04f6eb8 100644 --- a/progenitor-impl/tests/output/src/buildomat_builder.rs +++ b/progenitor-impl/tests/output/src/buildomat_builder.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///Task /// ///
JSON schema @@ -844,6 +874,7 @@ pub mod types { } } + /// Types for composing complex structures. pub mod builder { #[derive(Clone, Debug)] pub struct Task { @@ -920,8 +951,8 @@ pub mod types { } impl std::convert::TryFrom for super::Task { - type Error = String; - fn try_from(value: Task) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Task) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -1007,8 +1038,8 @@ pub mod types { } impl std::convert::TryFrom for super::TaskEvent { - type Error = String; - fn try_from(value: TaskEvent) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: TaskEvent) -> Result { Ok(Self { payload: value.payload?, seq: value.seq?, @@ -1080,8 +1111,8 @@ pub mod types { } impl std::convert::TryFrom for super::TaskOutput { - type Error = String; - fn try_from(value: TaskOutput) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: TaskOutput) -> Result { Ok(Self { id: value.id?, path: value.path?, @@ -1151,8 +1182,8 @@ pub mod types { } impl std::convert::TryFrom for super::TaskSubmit { - type Error = String; - fn try_from(value: TaskSubmit) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: TaskSubmit) -> Result { Ok(Self { name: value.name?, output_rules: value.output_rules?, @@ -1198,8 +1229,8 @@ pub mod types { } impl std::convert::TryFrom for super::TaskSubmitResult { - type Error = String; - fn try_from(value: TaskSubmitResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: TaskSubmitResult) -> Result { Ok(Self { id: value.id? }) } } @@ -1237,8 +1268,8 @@ pub mod types { } impl std::convert::TryFrom for super::UploadedChunk { - type Error = String; - fn try_from(value: UploadedChunk) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UploadedChunk) -> Result { Ok(Self { id: value.id? }) } } @@ -1276,8 +1307,8 @@ pub mod types { } impl std::convert::TryFrom for super::UserCreate { - type Error = String; - fn try_from(value: UserCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UserCreate) -> Result { Ok(Self { name: value.name? }) } } @@ -1341,8 +1372,8 @@ pub mod types { } impl std::convert::TryFrom for super::UserCreateResult { - type Error = String; - fn try_from(value: UserCreateResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UserCreateResult) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -1400,8 +1431,8 @@ pub mod types { } impl std::convert::TryFrom for super::WhoamiResult { - type Error = String; - fn try_from(value: WhoamiResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WhoamiResult) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -1505,8 +1536,8 @@ pub mod types { } impl std::convert::TryFrom for super::Worker { - type Error = String; - fn try_from(value: Worker) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Worker) -> Result { Ok(Self { deleted: value.deleted?, id: value.id?, @@ -1582,8 +1613,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerAddOutput { - type Error = String; - fn try_from(value: WorkerAddOutput) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerAddOutput) -> Result { Ok(Self { chunks: value.chunks?, path: value.path?, @@ -1653,8 +1684,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerAppendTask { - type Error = String; - fn try_from(value: WorkerAppendTask) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerAppendTask) -> Result { Ok(Self { payload: value.payload?, stream: value.stream?, @@ -1712,8 +1743,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerBootstrap { - type Error = String; - fn try_from(value: WorkerBootstrap) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerBootstrap) -> Result { Ok(Self { bootstrap: value.bootstrap?, token: value.token?, @@ -1757,8 +1788,10 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerBootstrapResult { - type Error = String; - fn try_from(value: WorkerBootstrapResult) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerBootstrapResult, + ) -> Result { Ok(Self { id: value.id? }) } } @@ -1796,8 +1829,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerCompleteTask { - type Error = String; - fn try_from(value: WorkerCompleteTask) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerCompleteTask) -> Result { Ok(Self { failed: value.failed?, }) @@ -1851,8 +1884,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerPingResult { - type Error = String; - fn try_from(value: WorkerPingResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerPingResult) -> Result { Ok(Self { poweroff: value.poweroff?, task: value.task?, @@ -1920,8 +1953,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerPingTask { - type Error = String; - fn try_from(value: WorkerPingTask) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerPingTask) -> Result { Ok(Self { id: value.id?, output_rules: value.output_rules?, @@ -1991,8 +2024,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerTask { - type Error = String; - fn try_from(value: WorkerTask) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerTask) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -2038,8 +2071,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkersResult { - type Error = String; - fn try_from(value: WorkersResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkersResult) -> Result { Ok(Self { workers: value.workers?, }) diff --git a/progenitor-impl/tests/output/src/buildomat_builder_tagged.rs b/progenitor-impl/tests/output/src/buildomat_builder_tagged.rs index a195db9..c80c1e9 100644 --- a/progenitor-impl/tests/output/src/buildomat_builder_tagged.rs +++ b/progenitor-impl/tests/output/src/buildomat_builder_tagged.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///Task /// ///
JSON schema @@ -844,6 +874,7 @@ pub mod types { } } + /// Types for composing complex structures. pub mod builder { #[derive(Clone, Debug)] pub struct Task { @@ -920,8 +951,8 @@ pub mod types { } impl std::convert::TryFrom for super::Task { - type Error = String; - fn try_from(value: Task) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Task) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -1007,8 +1038,8 @@ pub mod types { } impl std::convert::TryFrom for super::TaskEvent { - type Error = String; - fn try_from(value: TaskEvent) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: TaskEvent) -> Result { Ok(Self { payload: value.payload?, seq: value.seq?, @@ -1080,8 +1111,8 @@ pub mod types { } impl std::convert::TryFrom for super::TaskOutput { - type Error = String; - fn try_from(value: TaskOutput) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: TaskOutput) -> Result { Ok(Self { id: value.id?, path: value.path?, @@ -1151,8 +1182,8 @@ pub mod types { } impl std::convert::TryFrom for super::TaskSubmit { - type Error = String; - fn try_from(value: TaskSubmit) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: TaskSubmit) -> Result { Ok(Self { name: value.name?, output_rules: value.output_rules?, @@ -1198,8 +1229,8 @@ pub mod types { } impl std::convert::TryFrom for super::TaskSubmitResult { - type Error = String; - fn try_from(value: TaskSubmitResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: TaskSubmitResult) -> Result { Ok(Self { id: value.id? }) } } @@ -1237,8 +1268,8 @@ pub mod types { } impl std::convert::TryFrom for super::UploadedChunk { - type Error = String; - fn try_from(value: UploadedChunk) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UploadedChunk) -> Result { Ok(Self { id: value.id? }) } } @@ -1276,8 +1307,8 @@ pub mod types { } impl std::convert::TryFrom for super::UserCreate { - type Error = String; - fn try_from(value: UserCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UserCreate) -> Result { Ok(Self { name: value.name? }) } } @@ -1341,8 +1372,8 @@ pub mod types { } impl std::convert::TryFrom for super::UserCreateResult { - type Error = String; - fn try_from(value: UserCreateResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UserCreateResult) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -1400,8 +1431,8 @@ pub mod types { } impl std::convert::TryFrom for super::WhoamiResult { - type Error = String; - fn try_from(value: WhoamiResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WhoamiResult) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -1505,8 +1536,8 @@ pub mod types { } impl std::convert::TryFrom for super::Worker { - type Error = String; - fn try_from(value: Worker) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Worker) -> Result { Ok(Self { deleted: value.deleted?, id: value.id?, @@ -1582,8 +1613,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerAddOutput { - type Error = String; - fn try_from(value: WorkerAddOutput) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerAddOutput) -> Result { Ok(Self { chunks: value.chunks?, path: value.path?, @@ -1653,8 +1684,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerAppendTask { - type Error = String; - fn try_from(value: WorkerAppendTask) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerAppendTask) -> Result { Ok(Self { payload: value.payload?, stream: value.stream?, @@ -1712,8 +1743,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerBootstrap { - type Error = String; - fn try_from(value: WorkerBootstrap) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerBootstrap) -> Result { Ok(Self { bootstrap: value.bootstrap?, token: value.token?, @@ -1757,8 +1788,10 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerBootstrapResult { - type Error = String; - fn try_from(value: WorkerBootstrapResult) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: WorkerBootstrapResult, + ) -> Result { Ok(Self { id: value.id? }) } } @@ -1796,8 +1829,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerCompleteTask { - type Error = String; - fn try_from(value: WorkerCompleteTask) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerCompleteTask) -> Result { Ok(Self { failed: value.failed?, }) @@ -1851,8 +1884,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerPingResult { - type Error = String; - fn try_from(value: WorkerPingResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerPingResult) -> Result { Ok(Self { poweroff: value.poweroff?, task: value.task?, @@ -1920,8 +1953,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerPingTask { - type Error = String; - fn try_from(value: WorkerPingTask) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerPingTask) -> Result { Ok(Self { id: value.id?, output_rules: value.output_rules?, @@ -1991,8 +2024,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkerTask { - type Error = String; - fn try_from(value: WorkerTask) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkerTask) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -2038,8 +2071,8 @@ pub mod types { } impl std::convert::TryFrom for super::WorkersResult { - type Error = String; - fn try_from(value: WorkersResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: WorkersResult) -> Result { Ok(Self { workers: value.workers?, }) diff --git a/progenitor-impl/tests/output/src/buildomat_positional.rs b/progenitor-impl/tests/output/src/buildomat_positional.rs index c14f741..2261e7c 100644 --- a/progenitor-impl/tests/output/src/buildomat_positional.rs +++ b/progenitor-impl/tests/output/src/buildomat_positional.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///Task /// ///
JSON schema diff --git a/progenitor-impl/tests/output/src/keeper_builder.rs b/progenitor-impl/tests/output/src/keeper_builder.rs index 6b27f06..ba039b1 100644 --- a/progenitor-impl/tests/output/src/keeper_builder.rs +++ b/progenitor-impl/tests/output/src/keeper_builder.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///EnrolBody /// ///
JSON schema @@ -475,6 +505,7 @@ pub mod types { } } + /// Types for composing complex structures. pub mod builder { #[derive(Clone, Debug)] pub struct EnrolBody { @@ -515,8 +546,8 @@ pub mod types { } impl std::convert::TryFrom for super::EnrolBody { - type Error = String; - fn try_from(value: EnrolBody) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: EnrolBody) -> Result { Ok(Self { host: value.host?, key: value.key?, @@ -560,8 +591,8 @@ pub mod types { } impl std::convert::TryFrom for super::GlobalJobsResult { - type Error = String; - fn try_from(value: GlobalJobsResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: GlobalJobsResult) -> Result { Ok(Self { summary: value.summary?, }) @@ -627,8 +658,8 @@ pub mod types { } impl std::convert::TryFrom for super::OutputRecord { - type Error = String; - fn try_from(value: OutputRecord) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: OutputRecord) -> Result { Ok(Self { msg: value.msg?, stream: value.stream?, @@ -686,8 +717,8 @@ pub mod types { } impl std::convert::TryFrom for super::PingResult { - type Error = String; - fn try_from(value: PingResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: PingResult) -> Result { Ok(Self { host: value.host?, ok: value.ok?, @@ -767,8 +798,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportFinishBody { - type Error = String; - fn try_from(value: ReportFinishBody) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportFinishBody) -> Result { Ok(Self { duration_millis: value.duration_millis?, end_time: value.end_time?, @@ -864,8 +895,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportId { - type Error = String; - fn try_from(value: ReportId) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportId) -> Result { Ok(Self { host: value.host?, job: value.job?, @@ -927,8 +958,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportOutputBody { - type Error = String; - fn try_from(value: ReportOutputBody) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportOutputBody) -> Result { Ok(Self { id: value.id?, record: value.record?, @@ -972,8 +1003,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportResult { - type Error = String; - fn try_from(value: ReportResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportResult) -> Result { Ok(Self { existed_already: value.existed_already?, }) @@ -1039,8 +1070,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportStartBody { - type Error = String; - fn try_from(value: ReportStartBody) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportStartBody) -> Result { Ok(Self { id: value.id?, script: value.script?, @@ -1149,8 +1180,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportSummary { - type Error = String; - fn try_from(value: ReportSummary) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportSummary) -> Result { Ok(Self { age_seconds: value.age_seconds?, duration_seconds: value.duration_seconds?, diff --git a/progenitor-impl/tests/output/src/keeper_builder_tagged.rs b/progenitor-impl/tests/output/src/keeper_builder_tagged.rs index 143897a..8e9ab83 100644 --- a/progenitor-impl/tests/output/src/keeper_builder_tagged.rs +++ b/progenitor-impl/tests/output/src/keeper_builder_tagged.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///EnrolBody /// ///
JSON schema @@ -475,6 +505,7 @@ pub mod types { } } + /// Types for composing complex structures. pub mod builder { #[derive(Clone, Debug)] pub struct EnrolBody { @@ -515,8 +546,8 @@ pub mod types { } impl std::convert::TryFrom for super::EnrolBody { - type Error = String; - fn try_from(value: EnrolBody) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: EnrolBody) -> Result { Ok(Self { host: value.host?, key: value.key?, @@ -560,8 +591,8 @@ pub mod types { } impl std::convert::TryFrom for super::GlobalJobsResult { - type Error = String; - fn try_from(value: GlobalJobsResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: GlobalJobsResult) -> Result { Ok(Self { summary: value.summary?, }) @@ -627,8 +658,8 @@ pub mod types { } impl std::convert::TryFrom for super::OutputRecord { - type Error = String; - fn try_from(value: OutputRecord) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: OutputRecord) -> Result { Ok(Self { msg: value.msg?, stream: value.stream?, @@ -686,8 +717,8 @@ pub mod types { } impl std::convert::TryFrom for super::PingResult { - type Error = String; - fn try_from(value: PingResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: PingResult) -> Result { Ok(Self { host: value.host?, ok: value.ok?, @@ -767,8 +798,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportFinishBody { - type Error = String; - fn try_from(value: ReportFinishBody) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportFinishBody) -> Result { Ok(Self { duration_millis: value.duration_millis?, end_time: value.end_time?, @@ -864,8 +895,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportId { - type Error = String; - fn try_from(value: ReportId) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportId) -> Result { Ok(Self { host: value.host?, job: value.job?, @@ -927,8 +958,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportOutputBody { - type Error = String; - fn try_from(value: ReportOutputBody) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportOutputBody) -> Result { Ok(Self { id: value.id?, record: value.record?, @@ -972,8 +1003,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportResult { - type Error = String; - fn try_from(value: ReportResult) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportResult) -> Result { Ok(Self { existed_already: value.existed_already?, }) @@ -1039,8 +1070,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportStartBody { - type Error = String; - fn try_from(value: ReportStartBody) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportStartBody) -> Result { Ok(Self { id: value.id?, script: value.script?, @@ -1149,8 +1180,8 @@ pub mod types { } impl std::convert::TryFrom for super::ReportSummary { - type Error = String; - fn try_from(value: ReportSummary) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ReportSummary) -> Result { Ok(Self { age_seconds: value.age_seconds?, duration_seconds: value.duration_seconds?, diff --git a/progenitor-impl/tests/output/src/keeper_positional.rs b/progenitor-impl/tests/output/src/keeper_positional.rs index 2662470..4ce873a 100644 --- a/progenitor-impl/tests/output/src/keeper_positional.rs +++ b/progenitor-impl/tests/output/src/keeper_positional.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///EnrolBody /// ///
JSON schema diff --git a/progenitor-impl/tests/output/src/nexus_builder.rs b/progenitor-impl/tests/output/src/nexus_builder.rs index e48c617..4cf6bbe 100644 --- a/progenitor-impl/tests/output/src/nexus_builder.rs +++ b/progenitor-impl/tests/output/src/nexus_builder.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///Describes properties that should uniquely identify a Gimlet. /// ///
JSON schema @@ -414,10 +444,10 @@ pub mod types { } impl std::convert::TryFrom for BlockSize { - type Error = &'static str; - fn try_from(value: i64) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: i64) -> Result { if ![512_i64, 2048_i64, 4096_i64].contains(&value) { - Err("invalid value") + Err("invalid value".into()) } else { Ok(Self(value)) } @@ -1274,8 +1304,8 @@ pub mod types { } impl std::str::FromStr for DatumType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "bool" => Ok(Self::Bool), "i64" => Ok(Self::I64), @@ -1286,28 +1316,28 @@ pub mod types { "cumulative_f64" => Ok(Self::CumulativeF64), "histogram_i64" => Ok(Self::HistogramI64), "histogram_f64" => Ok(Self::HistogramF64), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for DatumType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for DatumType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for DatumType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -1807,8 +1837,8 @@ pub mod types { } impl std::str::FromStr for DiskMetricName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "activated" => Ok(Self::Activated), "flush" => Ok(Self::Flush), @@ -1816,28 +1846,28 @@ pub mod types { "read_bytes" => Ok(Self::ReadBytes), "write" => Ok(Self::Write), "write_bytes" => Ok(Self::WriteBytes), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for DiskMetricName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for DiskMetricName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for DiskMetricName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -2558,33 +2588,33 @@ pub mod types { } impl std::str::FromStr for FieldSource { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "target" => Ok(Self::Target), "metric" => Ok(Self::Metric), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for FieldSource { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for FieldSource { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for FieldSource { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -2653,36 +2683,36 @@ pub mod types { } impl std::str::FromStr for FieldType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "string" => Ok(Self::String), "i64" => Ok(Self::I64), "ip_addr" => Ok(Self::IpAddr), "uuid" => Ok(Self::Uuid), "bool" => Ok(Self::Bool), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for FieldType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for FieldType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for FieldType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -2741,34 +2771,34 @@ pub mod types { } impl std::str::FromStr for FleetRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for FleetRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for FleetRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for FleetRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -3546,32 +3576,32 @@ pub mod types { } impl std::str::FromStr for IdSortMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "id_ascending" => Ok(Self::IdAscending), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IdSortMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IdSortMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IdSortMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -3766,32 +3796,32 @@ pub mod types { } impl std::str::FromStr for IdentityProviderType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "saml" => Ok(Self::Saml), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IdentityProviderType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IdentityProviderType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IdentityProviderType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -3847,33 +3877,33 @@ pub mod types { } impl std::str::FromStr for IdentityType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "silo_user" => Ok(Self::SiloUser), "silo_group" => Ok(Self::SiloGroup), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IdentityType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IdentityType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IdentityType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5120,8 +5150,8 @@ pub mod types { } impl std::str::FromStr for InstanceState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "creating" => Ok(Self::Creating), "starting" => Ok(Self::Starting), @@ -5133,28 +5163,28 @@ pub mod types { "repairing" => Ok(Self::Repairing), "failed" => Ok(Self::Failed), "destroyed" => Ok(Self::Destroyed), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for InstanceState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for InstanceState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for InstanceState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5210,33 +5240,33 @@ pub mod types { } impl std::str::FromStr for IpKind { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "ephemeral" => Ok(Self::Ephemeral), "floating" => Ok(Self::Floating), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IpKind { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IpKind { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IpKind { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5282,35 +5312,35 @@ pub mod types { } impl std::str::FromStr for IpNet { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if let Ok(v) = value.parse() { Ok(Self::V4(v)) } else if let Ok(v) = value.parse() { Ok(Self::V6(v)) } else { - Err("string conversion failed for all variants") + Err("string conversion failed for all variants".into()) } } } impl std::convert::TryFrom<&str> for IpNet { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IpNet { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IpNet { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5749,8 +5779,8 @@ pub mod types { } impl std::str::FromStr for Ipv4Net { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new( "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ @@ -5763,29 +5793,30 @@ pub mod types { return Err("doesn't match pattern \ \"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ - ([8-9]|1[0-9]|2[0-9]|3[0-2])$\""); + ([8-9]|1[0-9]|2[0-9]|3[0-2])$\"" + .into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Ipv4Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Ipv4Net { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Ipv4Net { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5797,7 +5828,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -5890,8 +5923,8 @@ pub mod types { } impl std::str::FromStr for Ipv6Net { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new( "^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,\ 4}:){1,6}:)\\/([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$", @@ -5903,29 +5936,30 @@ pub mod types { return Err("doesn't match pattern \ \"^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,\ 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/\ - ([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$\""); + ([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$\"" + .into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Ipv6Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Ipv6Net { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Ipv6Net { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5937,7 +5971,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -6032,42 +6068,42 @@ pub mod types { } impl std::str::FromStr for L4PortRange { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 11usize { - return Err("longer than 11 characters"); + return Err("longer than 11 characters".into()); } if value.len() < 1usize { - return Err("shorter than 1 characters"); + return Err("shorter than 1 characters".into()); } if regress::Regex::new("^[0-9]{1,5}(-[0-9]{1,5})?$") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"^[0-9]{1,5}(-[0-9]{1,5})?$\""); + return Err("doesn't match pattern \"^[0-9]{1,5}(-[0-9]{1,5})?$\"".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for L4PortRange { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for L4PortRange { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for L4PortRange { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6079,7 +6115,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -6125,42 +6163,44 @@ pub mod types { } impl std::str::FromStr for MacAddr { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 17usize { - return Err("longer than 17 characters"); + return Err("longer than 17 characters".into()); } if value.len() < 17usize { - return Err("shorter than 17 characters"); + return Err("shorter than 17 characters".into()); } if regress::Regex::new("^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$\""); + return Err( + "doesn't match pattern \"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$\"".into(), + ); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for MacAddr { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for MacAddr { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for MacAddr { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6172,7 +6212,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -6316,33 +6358,33 @@ pub mod types { } impl std::str::FromStr for Name { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 63usize { - return Err("longer than 63 characters"); + return Err("longer than 63 characters".into()); } - if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"") ; } + if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Name { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Name { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Name { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6354,7 +6396,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -6400,35 +6444,35 @@ pub mod types { } impl std::str::FromStr for NameOrId { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if let Ok(v) = value.parse() { Ok(Self::Id(v)) } else if let Ok(v) = value.parse() { Ok(Self::Name(v)) } else { - Err("string conversion failed for all variants") + Err("string conversion failed for all variants".into()) } } } impl std::convert::TryFrom<&str> for NameOrId { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for NameOrId { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for NameOrId { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6530,34 +6574,34 @@ pub mod types { } impl std::str::FromStr for NameOrIdSortMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), "name_descending" => Ok(Self::NameDescending), "id_ascending" => Ok(Self::IdAscending), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for NameOrIdSortMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for NameOrIdSortMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for NameOrIdSortMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6618,32 +6662,32 @@ pub mod types { } impl std::str::FromStr for NameSortMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for NameSortMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for NameSortMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for NameSortMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -7277,34 +7321,34 @@ pub mod types { } impl std::str::FromStr for OrganizationRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for OrganizationRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for OrganizationRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for OrganizationRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -7499,32 +7543,32 @@ pub mod types { } impl std::str::FromStr for Password { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 512usize { - return Err("longer than 512 characters"); + return Err("longer than 512 characters".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Password { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Password { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Password { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -7536,7 +7580,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -7729,33 +7775,33 @@ pub mod types { } impl std::str::FromStr for PhysicalDiskType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "internal" => Ok(Self::Internal), "external" => Ok(Self::External), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for PhysicalDiskType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for PhysicalDiskType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for PhysicalDiskType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -7990,34 +8036,34 @@ pub mod types { } impl std::str::FromStr for ProjectRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for ProjectRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for ProjectRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for ProjectRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -8363,39 +8409,39 @@ pub mod types { } impl std::str::FromStr for RoleName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 63usize { - return Err("longer than 63 characters"); + return Err("longer than 63 characters".into()); } if regress::Regex::new("[a-z-]+\\.[a-z-]+") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"[a-z-]+\\.[a-z-]+\""); + return Err("doesn't match pattern \"[a-z-]+\\.[a-z-]+\"".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for RoleName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for RoleName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for RoleName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -8407,7 +8453,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -9003,35 +9051,35 @@ pub mod types { } impl std::str::FromStr for RouterRouteKind { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "default" => Ok(Self::Default), "vpc_subnet" => Ok(Self::VpcSubnet), "vpc_peering" => Ok(Self::VpcPeering), "custom" => Ok(Self::Custom), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for RouterRouteKind { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for RouterRouteKind { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for RouterRouteKind { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -9714,36 +9762,36 @@ pub mod types { } impl std::str::FromStr for SemverVersion { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new("^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\""); + return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\"".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for SemverVersion { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SemverVersion { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SemverVersion { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -9755,7 +9803,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -9813,32 +9863,32 @@ pub mod types { } impl std::str::FromStr for ServiceUsingCertificate { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "external_api" => Ok(Self::ExternalApi), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for ServiceUsingCertificate { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for ServiceUsingCertificate { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for ServiceUsingCertificate { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -10087,33 +10137,33 @@ pub mod types { } impl std::str::FromStr for SiloIdentityMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "saml_jit" => Ok(Self::SamlJit), "local_only" => Ok(Self::LocalOnly), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SiloIdentityMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SiloIdentityMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SiloIdentityMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -10224,34 +10274,34 @@ pub mod types { } impl std::str::FromStr for SiloRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SiloRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SiloRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SiloRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -10740,35 +10790,35 @@ pub mod types { } impl std::str::FromStr for SnapshotState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "creating" => Ok(Self::Creating), "ready" => Ok(Self::Ready), "faulted" => Ok(Self::Faulted), "destroyed" => Ok(Self::Destroyed), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SnapshotState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SnapshotState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SnapshotState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11056,34 +11106,34 @@ pub mod types { } impl std::str::FromStr for SystemMetricName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "virtual_disk_space_provisioned" => Ok(Self::VirtualDiskSpaceProvisioned), "cpus_provisioned" => Ok(Self::CpusProvisioned), "ram_provisioned" => Ok(Self::RamProvisioned), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SystemMetricName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SystemMetricName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SystemMetricName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11320,8 +11370,8 @@ pub mod types { } impl std::str::FromStr for TimeseriesName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new( "(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*)", ) @@ -11331,29 +11381,30 @@ pub mod types { { return Err("doesn't match pattern \ \"(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*\ - )(_([a-z0-9]+))*)\""); + )(_([a-z0-9]+))*)\"" + .into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for TimeseriesName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for TimeseriesName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for TimeseriesName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11365,7 +11416,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -11677,33 +11730,33 @@ pub mod types { } impl std::str::FromStr for UpdateStatus { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "updating" => Ok(Self::Updating), "steady" => Ok(Self::Steady), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for UpdateStatus { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for UpdateStatus { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for UpdateStatus { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11933,8 +11986,8 @@ pub mod types { } impl std::str::FromStr for UpdateableComponentType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "bootloader_for_rot" => Ok(Self::BootloaderForRot), "bootloader_for_sp" => Ok(Self::BootloaderForSp), @@ -11948,28 +12001,28 @@ pub mod types { "helios_host_phase1" => Ok(Self::HeliosHostPhase1), "helios_host_phase2" => Ok(Self::HeliosHostPhase2), "host_omicron" => Ok(Self::HostOmicron), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for UpdateableComponentType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for UpdateableComponentType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for UpdateableComponentType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -12252,33 +12305,33 @@ pub mod types { } impl std::str::FromStr for UserId { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 63usize { - return Err("longer than 63 characters"); + return Err("longer than 63 characters".into()); } - if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"") ; } + if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for UserId { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for UserId { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for UserId { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -12290,7 +12343,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -12876,33 +12931,33 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleAction { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "allow" => Ok(Self::Allow), "deny" => Ok(Self::Deny), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleAction { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleAction { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleAction { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -12957,33 +13012,33 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleDirection { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "inbound" => Ok(Self::Inbound), "outbound" => Ok(Self::Outbound), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleDirection { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleDirection { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleDirection { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -13273,34 +13328,34 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleProtocol { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "TCP" => Ok(Self::Tcp), "UDP" => Ok(Self::Udp), "ICMP" => Ok(Self::Icmp), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleProtocol { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleProtocol { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleProtocol { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -13355,33 +13410,33 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleStatus { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "disabled" => Ok(Self::Disabled), "enabled" => Ok(Self::Enabled), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleStatus { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleStatus { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleStatus { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -13967,33 +14022,33 @@ pub mod types { } impl std::str::FromStr for VpcRouterKind { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "system" => Ok(Self::System), "custom" => Ok(Self::Custom), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcRouterKind { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcRouterKind { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcRouterKind { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -14442,6 +14497,7 @@ pub mod types { } } + /// Types for composing complex structures. pub mod builder { #[derive(Clone, Debug)] pub struct Baseboard { @@ -14494,8 +14550,8 @@ pub mod types { } impl std::convert::TryFrom for super::Baseboard { - type Error = String; - fn try_from(value: Baseboard) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Baseboard) -> Result { Ok(Self { part: value.part?, revision: value.revision?, @@ -14553,8 +14609,8 @@ pub mod types { } impl std::convert::TryFrom for super::Bindouble { - type Error = String; - fn try_from(value: Bindouble) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Bindouble) -> Result { Ok(Self { count: value.count?, range: value.range?, @@ -14610,8 +14666,8 @@ pub mod types { } impl std::convert::TryFrom for super::Binint64 { - type Error = String; - fn try_from(value: Binint64) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Binint64) -> Result { Ok(Self { count: value.count?, range: value.range?, @@ -14715,8 +14771,8 @@ pub mod types { } impl std::convert::TryFrom for super::Certificate { - type Error = String; - fn try_from(value: Certificate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Certificate) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -14816,8 +14872,8 @@ pub mod types { } impl std::convert::TryFrom for super::CertificateCreate { - type Error = String; - fn try_from(value: CertificateCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: CertificateCreate) -> Result { Ok(Self { cert: value.cert?, description: value.description?, @@ -14879,8 +14935,10 @@ pub mod types { } impl std::convert::TryFrom for super::CertificateResultsPage { - type Error = String; - fn try_from(value: CertificateResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: CertificateResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -14972,8 +15030,8 @@ pub mod types { } impl std::convert::TryFrom for super::ComponentUpdate { - type Error = String; - fn try_from(value: ComponentUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ComponentUpdate) -> Result { Ok(Self { component_type: value.component_type?, id: value.id?, @@ -15035,8 +15093,10 @@ pub mod types { } impl std::convert::TryFrom for super::ComponentUpdateResultsPage { - type Error = String; - fn try_from(value: ComponentUpdateResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: ComponentUpdateResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -15092,8 +15152,8 @@ pub mod types { } impl std::convert::TryFrom for super::Cumulativedouble { - type Error = String; - fn try_from(value: Cumulativedouble) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Cumulativedouble) -> Result { Ok(Self { start_time: value.start_time?, value: value.value?, @@ -15149,8 +15209,8 @@ pub mod types { } impl std::convert::TryFrom for super::Cumulativeint64 { - type Error = String; - fn try_from(value: Cumulativeint64) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Cumulativeint64) -> Result { Ok(Self { start_time: value.start_time?, value: value.value?, @@ -15206,8 +15266,8 @@ pub mod types { } impl std::convert::TryFrom for super::DerEncodedKeyPair { - type Error = String; - fn try_from(value: DerEncodedKeyPair) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DerEncodedKeyPair) -> Result { Ok(Self { private_key: value.private_key?, public_cert: value.public_cert?, @@ -15275,8 +15335,10 @@ pub mod types { } impl std::convert::TryFrom for super::DeviceAccessTokenRequest { - type Error = String; - fn try_from(value: DeviceAccessTokenRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: DeviceAccessTokenRequest, + ) -> Result { Ok(Self { client_id: value.client_id?, device_code: value.device_code?, @@ -15322,8 +15384,8 @@ pub mod types { } impl std::convert::TryFrom for super::DeviceAuthRequest { - type Error = String; - fn try_from(value: DeviceAuthRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DeviceAuthRequest) -> Result { Ok(Self { client_id: value.client_id?, }) @@ -15365,8 +15427,8 @@ pub mod types { } impl std::convert::TryFrom for super::DeviceAuthVerify { - type Error = String; - fn try_from(value: DeviceAuthVerify) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DeviceAuthVerify) -> Result { Ok(Self { user_code: value.user_code?, }) @@ -15540,8 +15602,8 @@ pub mod types { } impl std::convert::TryFrom for super::Disk { - type Error = String; - fn try_from(value: Disk) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Disk) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -15641,8 +15703,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskCreate { - type Error = String; - fn try_from(value: DiskCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskCreate) -> Result { Ok(Self { description: value.description?, disk_source: value.disk_source?, @@ -15690,8 +15752,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskIdentifier { - type Error = String; - fn try_from(value: DiskIdentifier) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskIdentifier) -> Result { Ok(Self { name: value.name? }) } } @@ -15731,8 +15793,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskPath { - type Error = String; - fn try_from(value: DiskPath) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskPath) -> Result { Ok(Self { disk: value.disk? }) } } @@ -15784,8 +15846,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskResultsPage { - type Error = String; - fn try_from(value: DiskResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -15841,8 +15903,8 @@ pub mod types { } impl std::convert::TryFrom for super::Distribution { - type Error = String; - fn try_from(value: Distribution) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Distribution) -> Result { Ok(Self { name: value.name?, version: value.version?, @@ -15910,8 +15972,8 @@ pub mod types { } impl std::convert::TryFrom for super::Error { - type Error = String; - fn try_from(value: Error) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Error) -> Result { Ok(Self { error_code: value.error_code?, message: value.message?, @@ -15969,8 +16031,8 @@ pub mod types { } impl std::convert::TryFrom for super::ExternalIp { - type Error = String; - fn try_from(value: ExternalIp) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ExternalIp) -> Result { Ok(Self { ip: value.ip?, kind: value.kind?, @@ -16026,8 +16088,10 @@ pub mod types { } impl std::convert::TryFrom for super::ExternalIpResultsPage { - type Error = String; - fn try_from(value: ExternalIpResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: ExternalIpResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -16095,8 +16159,8 @@ pub mod types { } impl std::convert::TryFrom for super::FieldSchema { - type Error = String; - fn try_from(value: FieldSchema) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: FieldSchema) -> Result { Ok(Self { name: value.name?, source: value.source?, @@ -16145,8 +16209,8 @@ pub mod types { } impl std::convert::TryFrom for super::FleetRolePolicy { - type Error = String; - fn try_from(value: FleetRolePolicy) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: FleetRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -16212,8 +16276,10 @@ pub mod types { } impl std::convert::TryFrom for super::FleetRoleRoleAssignment { - type Error = String; - fn try_from(value: FleetRoleRoleAssignment) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: FleetRoleRoleAssignment, + ) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -16379,8 +16445,8 @@ pub mod types { } impl std::convert::TryFrom for super::GlobalImage { - type Error = String; - fn try_from(value: GlobalImage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: GlobalImage) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -16490,8 +16556,8 @@ pub mod types { } impl std::convert::TryFrom for super::GlobalImageCreate { - type Error = String; - fn try_from(value: GlobalImageCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: GlobalImageCreate) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -16553,8 +16619,10 @@ pub mod types { } impl std::convert::TryFrom for super::GlobalImageResultsPage { - type Error = String; - fn try_from(value: GlobalImageResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: GlobalImageResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -16622,8 +16690,8 @@ pub mod types { } impl std::convert::TryFrom for super::Group { - type Error = String; - fn try_from(value: Group) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Group) -> Result { Ok(Self { display_name: value.display_name?, id: value.id?, @@ -16681,8 +16749,8 @@ pub mod types { } impl std::convert::TryFrom for super::GroupResultsPage { - type Error = String; - fn try_from(value: GroupResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: GroupResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -16750,8 +16818,8 @@ pub mod types { } impl std::convert::TryFrom for super::Histogramdouble { - type Error = String; - fn try_from(value: Histogramdouble) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Histogramdouble) -> Result { Ok(Self { bins: value.bins?, n_samples: value.n_samples?, @@ -16821,8 +16889,8 @@ pub mod types { } impl std::convert::TryFrom for super::Histogramint64 { - type Error = String; - fn try_from(value: Histogramint64) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Histogramint64) -> Result { Ok(Self { bins: value.bins?, n_samples: value.n_samples?, @@ -16928,8 +16996,8 @@ pub mod types { } impl std::convert::TryFrom for super::IdentityProvider { - type Error = String; - fn try_from(value: IdentityProvider) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IdentityProvider) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -16993,8 +17061,10 @@ pub mod types { } impl std::convert::TryFrom for super::IdentityProviderResultsPage { - type Error = String; - fn try_from(value: IdentityProviderResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: IdentityProviderResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -17158,8 +17228,8 @@ pub mod types { } impl std::convert::TryFrom for super::Image { - type Error = String; - fn try_from(value: Image) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Image) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -17257,8 +17327,8 @@ pub mod types { } impl std::convert::TryFrom for super::ImageCreate { - type Error = String; - fn try_from(value: ImageCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ImageCreate) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -17318,8 +17388,8 @@ pub mod types { } impl std::convert::TryFrom for super::ImageResultsPage { - type Error = String; - fn try_from(value: ImageResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ImageResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -17488,8 +17558,8 @@ pub mod types { } impl std::convert::TryFrom for super::Instance { - type Error = String; - fn try_from(value: Instance) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Instance) -> Result { Ok(Self { description: value.description?, hostname: value.hostname?, @@ -17662,8 +17732,8 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceCreate { - type Error = String; - fn try_from(value: InstanceCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: InstanceCreate) -> Result { Ok(Self { description: value.description?, disks: value.disks?, @@ -17723,8 +17793,8 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceMigrate { - type Error = String; - fn try_from(value: InstanceMigrate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: InstanceMigrate) -> Result { Ok(Self { dst_sled_id: value.dst_sled_id?, }) @@ -17778,8 +17848,8 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceResultsPage { - type Error = String; - fn try_from(value: InstanceResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: InstanceResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -17838,8 +17908,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceSerialConsoleData { - type Error = String; - fn try_from(value: InstanceSerialConsoleData) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceSerialConsoleData, + ) -> Result { Ok(Self { data: value.data?, last_byte_offset: value.last_byte_offset?, @@ -17931,8 +18003,8 @@ pub mod types { } impl std::convert::TryFrom for super::IpPool { - type Error = String; - fn try_from(value: IpPool) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IpPool) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -17994,8 +18066,8 @@ pub mod types { } impl std::convert::TryFrom for super::IpPoolCreate { - type Error = String; - fn try_from(value: IpPoolCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IpPoolCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -18063,8 +18135,8 @@ pub mod types { } impl std::convert::TryFrom for super::IpPoolRange { - type Error = String; - fn try_from(value: IpPoolRange) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IpPoolRange) -> Result { Ok(Self { id: value.id?, range: value.range?, @@ -18122,8 +18194,10 @@ pub mod types { } impl std::convert::TryFrom for super::IpPoolRangeResultsPage { - type Error = String; - fn try_from(value: IpPoolRangeResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolRangeResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -18179,8 +18253,8 @@ pub mod types { } impl std::convert::TryFrom for super::IpPoolResultsPage { - type Error = String; - fn try_from(value: IpPoolResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IpPoolResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -18236,8 +18310,8 @@ pub mod types { } impl std::convert::TryFrom for super::IpPoolUpdate { - type Error = String; - fn try_from(value: IpPoolUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IpPoolUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -18293,8 +18367,8 @@ pub mod types { } impl std::convert::TryFrom for super::Ipv4Range { - type Error = String; - fn try_from(value: Ipv4Range) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Ipv4Range) -> Result { Ok(Self { first: value.first?, last: value.last?, @@ -18350,8 +18424,8 @@ pub mod types { } impl std::convert::TryFrom for super::Ipv6Range { - type Error = String; - fn try_from(value: Ipv6Range) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Ipv6Range) -> Result { Ok(Self { first: value.first?, last: value.last?, @@ -18407,8 +18481,8 @@ pub mod types { } impl std::convert::TryFrom for super::Measurement { - type Error = String; - fn try_from(value: Measurement) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Measurement) -> Result { Ok(Self { datum: value.datum?, timestamp: value.timestamp?, @@ -18464,8 +18538,10 @@ pub mod types { } impl std::convert::TryFrom for super::MeasurementResultsPage { - type Error = String; - fn try_from(value: MeasurementResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: MeasurementResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -18629,8 +18705,8 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterface { - type Error = String; - fn try_from(value: NetworkInterface) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: NetworkInterface) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -18740,8 +18816,10 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterfaceCreate { - type Error = String; - fn try_from(value: NetworkInterfaceCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceCreate, + ) -> Result { Ok(Self { description: value.description?, ip: value.ip?, @@ -18803,8 +18881,10 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterfaceResultsPage { - type Error = String; - fn try_from(value: NetworkInterfaceResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -18872,8 +18952,10 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterfaceUpdate { - type Error = String; - fn try_from(value: NetworkInterfaceUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceUpdate, + ) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -18967,8 +19049,8 @@ pub mod types { } impl std::convert::TryFrom for super::Organization { - type Error = String; - fn try_from(value: Organization) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Organization) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -19030,8 +19112,8 @@ pub mod types { } impl std::convert::TryFrom for super::OrganizationCreate { - type Error = String; - fn try_from(value: OrganizationCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: OrganizationCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -19087,8 +19169,10 @@ pub mod types { } impl std::convert::TryFrom for super::OrganizationResultsPage { - type Error = String; - fn try_from(value: OrganizationResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -19135,8 +19219,10 @@ pub mod types { } impl std::convert::TryFrom for super::OrganizationRolePolicy { - type Error = String; - fn try_from(value: OrganizationRolePolicy) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationRolePolicy, + ) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -19204,8 +19290,10 @@ pub mod types { impl std::convert::TryFrom for super::OrganizationRoleRoleAssignment { - type Error = String; - fn try_from(value: OrganizationRoleRoleAssignment) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationRoleRoleAssignment, + ) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -19263,8 +19351,8 @@ pub mod types { } impl std::convert::TryFrom for super::OrganizationUpdate { - type Error = String; - fn try_from(value: OrganizationUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: OrganizationUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -19392,8 +19480,8 @@ pub mod types { } impl std::convert::TryFrom for super::PhysicalDisk { - type Error = String; - fn try_from(value: PhysicalDisk) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: PhysicalDisk) -> Result { Ok(Self { disk_type: value.disk_type?, id: value.id?, @@ -19461,8 +19549,10 @@ pub mod types { } impl std::convert::TryFrom for super::PhysicalDiskResultsPage { - type Error = String; - fn try_from(value: PhysicalDiskResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: PhysicalDiskResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -19566,8 +19656,8 @@ pub mod types { } impl std::convert::TryFrom for super::Project { - type Error = String; - fn try_from(value: Project) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Project) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -19631,8 +19721,8 @@ pub mod types { } impl std::convert::TryFrom for super::ProjectCreate { - type Error = String; - fn try_from(value: ProjectCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ProjectCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -19688,8 +19778,8 @@ pub mod types { } impl std::convert::TryFrom for super::ProjectResultsPage { - type Error = String; - fn try_from(value: ProjectResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ProjectResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -19736,8 +19826,8 @@ pub mod types { } impl std::convert::TryFrom for super::ProjectRolePolicy { - type Error = String; - fn try_from(value: ProjectRolePolicy) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ProjectRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -19803,8 +19893,10 @@ pub mod types { } impl std::convert::TryFrom for super::ProjectRoleRoleAssignment { - type Error = String; - fn try_from(value: ProjectRoleRoleAssignment) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectRoleRoleAssignment, + ) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -19862,8 +19954,8 @@ pub mod types { } impl std::convert::TryFrom for super::ProjectUpdate { - type Error = String; - fn try_from(value: ProjectUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ProjectUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -19931,8 +20023,8 @@ pub mod types { } impl std::convert::TryFrom for super::Rack { - type Error = String; - fn try_from(value: Rack) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Rack) -> Result { Ok(Self { id: value.id?, time_created: value.time_created?, @@ -19990,8 +20082,8 @@ pub mod types { } impl std::convert::TryFrom for super::RackResultsPage { - type Error = String; - fn try_from(value: RackResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: RackResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -20047,8 +20139,8 @@ pub mod types { } impl std::convert::TryFrom for super::Role { - type Error = String; - fn try_from(value: Role) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Role) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -20104,8 +20196,8 @@ pub mod types { } impl std::convert::TryFrom for super::RoleResultsPage { - type Error = String; - fn try_from(value: RoleResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: RoleResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -20245,8 +20337,8 @@ pub mod types { } impl std::convert::TryFrom for super::RouterRoute { - type Error = String; - fn try_from(value: RouterRoute) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: RouterRoute) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -20340,8 +20432,10 @@ pub mod types { } impl std::convert::TryFrom for super::RouterRouteCreateParams { - type Error = String; - fn try_from(value: RouterRouteCreateParams) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteCreateParams, + ) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -20401,8 +20495,10 @@ pub mod types { } impl std::convert::TryFrom for super::RouterRouteResultsPage { - type Error = String; - fn try_from(value: RouterRouteResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -20482,8 +20578,10 @@ pub mod types { } impl std::convert::TryFrom for super::RouterRouteUpdateParams { - type Error = String; - fn try_from(value: RouterRouteUpdateParams) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteUpdateParams, + ) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -20543,8 +20641,8 @@ pub mod types { } impl std::convert::TryFrom for super::Saga { - type Error = String; - fn try_from(value: Saga) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Saga) -> Result { Ok(Self { id: value.id?, state: value.state?, @@ -20600,8 +20698,8 @@ pub mod types { } impl std::convert::TryFrom for super::SagaResultsPage { - type Error = String; - fn try_from(value: SagaResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SagaResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -20770,8 +20868,10 @@ pub mod types { } impl std::convert::TryFrom for super::SamlIdentityProvider { - type Error = String; - fn try_from(value: SamlIdentityProvider) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: SamlIdentityProvider, + ) -> Result { Ok(Self { acs_url: value.acs_url?, description: value.description?, @@ -20954,8 +21054,10 @@ pub mod types { } impl std::convert::TryFrom for super::SamlIdentityProviderCreate { - type Error = String; - fn try_from(value: SamlIdentityProviderCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: SamlIdentityProviderCreate, + ) -> Result { Ok(Self { acs_url: value.acs_url?, description: value.description?, @@ -21087,8 +21189,8 @@ pub mod types { } impl std::convert::TryFrom for super::Silo { - type Error = String; - fn try_from(value: Silo) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Silo) -> Result { Ok(Self { description: value.description?, discoverable: value.discoverable?, @@ -21193,8 +21295,8 @@ pub mod types { } impl std::convert::TryFrom for super::SiloCreate { - type Error = String; - fn try_from(value: SiloCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SiloCreate) -> Result { Ok(Self { admin_group_name: value.admin_group_name?, description: value.description?, @@ -21256,8 +21358,8 @@ pub mod types { } impl std::convert::TryFrom for super::SiloResultsPage { - type Error = String; - fn try_from(value: SiloResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SiloResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -21304,8 +21406,8 @@ pub mod types { } impl std::convert::TryFrom for super::SiloRolePolicy { - type Error = String; - fn try_from(value: SiloRolePolicy) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SiloRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -21371,8 +21473,10 @@ pub mod types { } impl std::convert::TryFrom for super::SiloRoleRoleAssignment { - type Error = String; - fn try_from(value: SiloRoleRoleAssignment) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: SiloRoleRoleAssignment, + ) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -21466,8 +21570,8 @@ pub mod types { } impl std::convert::TryFrom for super::Sled { - type Error = String; - fn try_from(value: Sled) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Sled) -> Result { Ok(Self { baseboard: value.baseboard?, id: value.id?, @@ -21529,8 +21633,8 @@ pub mod types { } impl std::convert::TryFrom for super::SledResultsPage { - type Error = String; - fn try_from(value: SledResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SledResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -21670,8 +21774,8 @@ pub mod types { } impl std::convert::TryFrom for super::Snapshot { - type Error = String; - fn try_from(value: Snapshot) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Snapshot) -> Result { Ok(Self { description: value.description?, disk_id: value.disk_id?, @@ -21753,8 +21857,8 @@ pub mod types { } impl std::convert::TryFrom for super::SnapshotCreate { - type Error = String; - fn try_from(value: SnapshotCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SnapshotCreate) -> Result { Ok(Self { description: value.description?, disk: value.disk?, @@ -21812,8 +21916,8 @@ pub mod types { } impl std::convert::TryFrom for super::SnapshotResultsPage { - type Error = String; - fn try_from(value: SnapshotResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SnapshotResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -21857,8 +21961,8 @@ pub mod types { } impl std::convert::TryFrom for super::SpoofLoginBody { - type Error = String; - fn try_from(value: SpoofLoginBody) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SpoofLoginBody) -> Result { Ok(Self { username: value.username?, }) @@ -21972,8 +22076,8 @@ pub mod types { } impl std::convert::TryFrom for super::SshKey { - type Error = String; - fn try_from(value: SshKey) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SshKey) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -22051,8 +22155,8 @@ pub mod types { } impl std::convert::TryFrom for super::SshKeyCreate { - type Error = String; - fn try_from(value: SshKeyCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SshKeyCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -22110,8 +22214,8 @@ pub mod types { } impl std::convert::TryFrom for super::SshKeyResultsPage { - type Error = String; - fn try_from(value: SshKeyResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SshKeyResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -22191,8 +22295,8 @@ pub mod types { } impl std::convert::TryFrom for super::SystemUpdate { - type Error = String; - fn try_from(value: SystemUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SystemUpdate) -> Result { Ok(Self { id: value.id?, time_created: value.time_created?, @@ -22252,8 +22356,10 @@ pub mod types { } impl std::convert::TryFrom for super::SystemUpdateResultsPage { - type Error = String; - fn try_from(value: SystemUpdateResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: SystemUpdateResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -22297,8 +22403,8 @@ pub mod types { } impl std::convert::TryFrom for super::SystemUpdateStart { - type Error = String; - fn try_from(value: SystemUpdateStart) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SystemUpdateStart) -> Result { Ok(Self { version: value.version?, }) @@ -22352,8 +22458,8 @@ pub mod types { } impl std::convert::TryFrom for super::SystemVersion { - type Error = String; - fn try_from(value: SystemVersion) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SystemVersion) -> Result { Ok(Self { status: value.status?, version_range: value.version_range?, @@ -22433,8 +22539,8 @@ pub mod types { } impl std::convert::TryFrom for super::TimeseriesSchema { - type Error = String; - fn try_from(value: TimeseriesSchema) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: TimeseriesSchema) -> Result { Ok(Self { created: value.created?, datum_type: value.datum_type?, @@ -22494,8 +22600,10 @@ pub mod types { } impl std::convert::TryFrom for super::TimeseriesSchemaResultsPage { - type Error = String; - fn try_from(value: TimeseriesSchemaResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: TimeseriesSchemaResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -22587,8 +22695,8 @@ pub mod types { } impl std::convert::TryFrom for super::UpdateDeployment { - type Error = String; - fn try_from(value: UpdateDeployment) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UpdateDeployment) -> Result { Ok(Self { id: value.id?, status: value.status?, @@ -22650,8 +22758,10 @@ pub mod types { } impl std::convert::TryFrom for super::UpdateDeploymentResultsPage { - type Error = String; - fn try_from(value: UpdateDeploymentResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateDeploymentResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -22779,8 +22889,8 @@ pub mod types { } impl std::convert::TryFrom for super::UpdateableComponent { - type Error = String; - fn try_from(value: UpdateableComponent) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UpdateableComponent) -> Result { Ok(Self { component_type: value.component_type?, device_id: value.device_id?, @@ -22850,8 +22960,10 @@ pub mod types { impl std::convert::TryFrom for super::UpdateableComponentResultsPage { - type Error = String; - fn try_from(value: UpdateableComponentResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateableComponentResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -22919,8 +23031,8 @@ pub mod types { } impl std::convert::TryFrom for super::User { - type Error = String; - fn try_from(value: User) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: User) -> Result { Ok(Self { display_name: value.display_name?, id: value.id?, @@ -23014,8 +23126,8 @@ pub mod types { } impl std::convert::TryFrom for super::UserBuiltin { - type Error = String; - fn try_from(value: UserBuiltin) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UserBuiltin) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -23077,8 +23189,10 @@ pub mod types { } impl std::convert::TryFrom for super::UserBuiltinResultsPage { - type Error = String; - fn try_from(value: UserBuiltinResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: UserBuiltinResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -23134,8 +23248,8 @@ pub mod types { } impl std::convert::TryFrom for super::UserCreate { - type Error = String; - fn try_from(value: UserCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UserCreate) -> Result { Ok(Self { external_id: value.external_id?, password: value.password?, @@ -23191,8 +23305,8 @@ pub mod types { } impl std::convert::TryFrom for super::UserResultsPage { - type Error = String; - fn try_from(value: UserResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UserResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -23248,8 +23362,10 @@ pub mod types { } impl std::convert::TryFrom for super::UsernamePasswordCredentials { - type Error = String; - fn try_from(value: UsernamePasswordCredentials) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: UsernamePasswordCredentials, + ) -> Result { Ok(Self { password: value.password?, username: value.username?, @@ -23305,8 +23421,8 @@ pub mod types { } impl std::convert::TryFrom for super::VersionRange { - type Error = String; - fn try_from(value: VersionRange) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VersionRange) -> Result { Ok(Self { high: value.high?, low: value.low?, @@ -23449,8 +23565,8 @@ pub mod types { } impl std::convert::TryFrom for super::Vpc { - type Error = String; - fn try_from(value: Vpc) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Vpc) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, @@ -23544,8 +23660,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcCreate { - type Error = String; - fn try_from(value: VpcCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcCreate) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, @@ -23725,8 +23841,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcFirewallRule { - type Error = String; - fn try_from(value: VpcFirewallRule) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcFirewallRule) -> Result { Ok(Self { action: value.action?, description: value.description?, @@ -23814,8 +23930,10 @@ pub mod types { } impl std::convert::TryFrom for super::VpcFirewallRuleFilter { - type Error = String; - fn try_from(value: VpcFirewallRuleFilter) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleFilter, + ) -> Result { Ok(Self { hosts: value.hosts?, ports: value.ports?, @@ -23945,8 +24063,10 @@ pub mod types { } impl std::convert::TryFrom for super::VpcFirewallRuleUpdate { - type Error = String; - fn try_from(value: VpcFirewallRuleUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleUpdate, + ) -> Result { Ok(Self { action: value.action?, description: value.description?, @@ -24002,8 +24122,10 @@ pub mod types { } impl std::convert::TryFrom for super::VpcFirewallRuleUpdateParams { - type Error = String; - fn try_from(value: VpcFirewallRuleUpdateParams) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleUpdateParams, + ) -> Result { Ok(Self { rules: value.rules?, }) @@ -24045,8 +24167,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcFirewallRules { - type Error = String; - fn try_from(value: VpcFirewallRules) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcFirewallRules) -> Result { Ok(Self { rules: value.rules?, }) @@ -24100,8 +24222,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcResultsPage { - type Error = String; - fn try_from(value: VpcResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -24217,8 +24339,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcRouter { - type Error = String; - fn try_from(value: VpcRouter) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcRouter) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -24284,8 +24406,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcRouterCreate { - type Error = String; - fn try_from(value: VpcRouterCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcRouterCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -24341,8 +24463,10 @@ pub mod types { } impl std::convert::TryFrom for super::VpcRouterResultsPage { - type Error = String; - fn try_from(value: VpcRouterResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: VpcRouterResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -24398,8 +24522,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcRouterUpdate { - type Error = String; - fn try_from(value: VpcRouterUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcRouterUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -24527,8 +24651,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcSubnet { - type Error = String; - fn try_from(value: VpcSubnet) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcSubnet) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -24620,8 +24744,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcSubnetCreate { - type Error = String; - fn try_from(value: VpcSubnetCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcSubnetCreate) -> Result { Ok(Self { description: value.description?, ipv4_block: value.ipv4_block?, @@ -24681,8 +24805,10 @@ pub mod types { } impl std::convert::TryFrom for super::VpcSubnetResultsPage { - type Error = String; - fn try_from(value: VpcSubnetResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: VpcSubnetResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -24738,8 +24864,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcSubnetUpdate { - type Error = String; - fn try_from(value: VpcSubnetUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcSubnetUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -24807,8 +24933,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcUpdate { - type Error = String; - fn try_from(value: VpcUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcUpdate) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, @@ -24828,6 +24954,7 @@ pub mod types { } } + /// Generation of default values for serde. pub mod defaults { pub(super) fn default_bool() -> bool { V diff --git a/progenitor-impl/tests/output/src/nexus_builder_tagged.rs b/progenitor-impl/tests/output/src/nexus_builder_tagged.rs index 0cc90f2..fcbd0af 100644 --- a/progenitor-impl/tests/output/src/nexus_builder_tagged.rs +++ b/progenitor-impl/tests/output/src/nexus_builder_tagged.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///Describes properties that should uniquely identify a Gimlet. /// ///
JSON schema @@ -414,10 +444,10 @@ pub mod types { } impl std::convert::TryFrom for BlockSize { - type Error = &'static str; - fn try_from(value: i64) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: i64) -> Result { if ![512_i64, 2048_i64, 4096_i64].contains(&value) { - Err("invalid value") + Err("invalid value".into()) } else { Ok(Self(value)) } @@ -1262,8 +1292,8 @@ pub mod types { } impl std::str::FromStr for DatumType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "bool" => Ok(Self::Bool), "i64" => Ok(Self::I64), @@ -1274,28 +1304,28 @@ pub mod types { "cumulative_f64" => Ok(Self::CumulativeF64), "histogram_i64" => Ok(Self::HistogramI64), "histogram_f64" => Ok(Self::HistogramF64), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for DatumType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for DatumType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for DatumType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -1783,8 +1813,8 @@ pub mod types { } impl std::str::FromStr for DiskMetricName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "activated" => Ok(Self::Activated), "flush" => Ok(Self::Flush), @@ -1792,28 +1822,28 @@ pub mod types { "read_bytes" => Ok(Self::ReadBytes), "write" => Ok(Self::Write), "write_bytes" => Ok(Self::WriteBytes), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for DiskMetricName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for DiskMetricName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for DiskMetricName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -2522,33 +2552,33 @@ pub mod types { } impl std::str::FromStr for FieldSource { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "target" => Ok(Self::Target), "metric" => Ok(Self::Metric), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for FieldSource { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for FieldSource { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for FieldSource { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -2605,36 +2635,36 @@ pub mod types { } impl std::str::FromStr for FieldType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "string" => Ok(Self::String), "i64" => Ok(Self::I64), "ip_addr" => Ok(Self::IpAddr), "uuid" => Ok(Self::Uuid), "bool" => Ok(Self::Bool), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for FieldType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for FieldType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for FieldType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -2681,34 +2711,34 @@ pub mod types { } impl std::str::FromStr for FleetRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for FleetRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for FleetRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for FleetRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -3474,32 +3504,32 @@ pub mod types { } impl std::str::FromStr for IdSortMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "id_ascending" => Ok(Self::IdAscending), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IdSortMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IdSortMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IdSortMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -3682,32 +3712,32 @@ pub mod types { } impl std::str::FromStr for IdentityProviderType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "saml" => Ok(Self::Saml), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IdentityProviderType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IdentityProviderType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IdentityProviderType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -3751,33 +3781,33 @@ pub mod types { } impl std::str::FromStr for IdentityType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "silo_user" => Ok(Self::SiloUser), "silo_group" => Ok(Self::SiloGroup), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IdentityType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IdentityType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IdentityType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5012,8 +5042,8 @@ pub mod types { } impl std::str::FromStr for InstanceState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "creating" => Ok(Self::Creating), "starting" => Ok(Self::Starting), @@ -5025,28 +5055,28 @@ pub mod types { "repairing" => Ok(Self::Repairing), "failed" => Ok(Self::Failed), "destroyed" => Ok(Self::Destroyed), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for InstanceState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for InstanceState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for InstanceState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5090,33 +5120,33 @@ pub mod types { } impl std::str::FromStr for IpKind { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "ephemeral" => Ok(Self::Ephemeral), "floating" => Ok(Self::Floating), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IpKind { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IpKind { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IpKind { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5162,35 +5192,35 @@ pub mod types { } impl std::str::FromStr for IpNet { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if let Ok(v) = value.parse() { Ok(Self::V4(v)) } else if let Ok(v) = value.parse() { Ok(Self::V6(v)) } else { - Err("string conversion failed for all variants") + Err("string conversion failed for all variants".into()) } } } impl std::convert::TryFrom<&str> for IpNet { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IpNet { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IpNet { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5627,8 +5657,8 @@ pub mod types { } impl std::str::FromStr for Ipv4Net { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new( "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ @@ -5641,29 +5671,30 @@ pub mod types { return Err("doesn't match pattern \ \"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ - ([8-9]|1[0-9]|2[0-9]|3[0-2])$\""); + ([8-9]|1[0-9]|2[0-9]|3[0-2])$\"" + .into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Ipv4Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Ipv4Net { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Ipv4Net { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5675,7 +5706,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -5766,8 +5799,8 @@ pub mod types { } impl std::str::FromStr for Ipv6Net { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new( "^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,\ 4}:){1,6}:)\\/([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$", @@ -5779,29 +5812,30 @@ pub mod types { return Err("doesn't match pattern \ \"^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,\ 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/\ - ([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$\""); + ([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$\"" + .into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Ipv6Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Ipv6Net { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Ipv6Net { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5813,7 +5847,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -5906,42 +5942,42 @@ pub mod types { } impl std::str::FromStr for L4PortRange { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 11usize { - return Err("longer than 11 characters"); + return Err("longer than 11 characters".into()); } if value.len() < 1usize { - return Err("shorter than 1 characters"); + return Err("shorter than 1 characters".into()); } if regress::Regex::new("^[0-9]{1,5}(-[0-9]{1,5})?$") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"^[0-9]{1,5}(-[0-9]{1,5})?$\""); + return Err("doesn't match pattern \"^[0-9]{1,5}(-[0-9]{1,5})?$\"".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for L4PortRange { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for L4PortRange { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for L4PortRange { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5953,7 +5989,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -5997,42 +6035,44 @@ pub mod types { } impl std::str::FromStr for MacAddr { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 17usize { - return Err("longer than 17 characters"); + return Err("longer than 17 characters".into()); } if value.len() < 17usize { - return Err("shorter than 17 characters"); + return Err("shorter than 17 characters".into()); } if regress::Regex::new("^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$\""); + return Err( + "doesn't match pattern \"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$\"".into(), + ); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for MacAddr { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for MacAddr { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for MacAddr { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6044,7 +6084,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -6186,33 +6228,33 @@ pub mod types { } impl std::str::FromStr for Name { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 63usize { - return Err("longer than 63 characters"); + return Err("longer than 63 characters".into()); } - if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"") ; } + if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Name { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Name { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Name { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6224,7 +6266,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -6270,35 +6314,35 @@ pub mod types { } impl std::str::FromStr for NameOrId { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if let Ok(v) = value.parse() { Ok(Self::Id(v)) } else if let Ok(v) = value.parse() { Ok(Self::Name(v)) } else { - Err("string conversion failed for all variants") + Err("string conversion failed for all variants".into()) } } } impl std::convert::TryFrom<&str> for NameOrId { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for NameOrId { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for NameOrId { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6388,34 +6432,34 @@ pub mod types { } impl std::str::FromStr for NameOrIdSortMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), "name_descending" => Ok(Self::NameDescending), "id_ascending" => Ok(Self::IdAscending), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for NameOrIdSortMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for NameOrIdSortMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for NameOrIdSortMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6464,32 +6508,32 @@ pub mod types { } impl std::str::FromStr for NameSortMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for NameSortMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for NameSortMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for NameSortMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -7100,34 +7144,34 @@ pub mod types { } impl std::str::FromStr for OrganizationRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for OrganizationRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for OrganizationRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for OrganizationRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -7320,32 +7364,32 @@ pub mod types { } impl std::str::FromStr for Password { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 512usize { - return Err("longer than 512 characters"); + return Err("longer than 512 characters".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Password { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Password { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Password { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -7357,7 +7401,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -7538,33 +7584,33 @@ pub mod types { } impl std::str::FromStr for PhysicalDiskType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "internal" => Ok(Self::Internal), "external" => Ok(Self::External), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for PhysicalDiskType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for PhysicalDiskType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for PhysicalDiskType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -7787,34 +7833,34 @@ pub mod types { } impl std::str::FromStr for ProjectRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for ProjectRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for ProjectRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for ProjectRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -8158,39 +8204,39 @@ pub mod types { } impl std::str::FromStr for RoleName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 63usize { - return Err("longer than 63 characters"); + return Err("longer than 63 characters".into()); } if regress::Regex::new("[a-z-]+\\.[a-z-]+") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"[a-z-]+\\.[a-z-]+\""); + return Err("doesn't match pattern \"[a-z-]+\\.[a-z-]+\"".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for RoleName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for RoleName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for RoleName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -8202,7 +8248,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -8786,35 +8834,35 @@ pub mod types { } impl std::str::FromStr for RouterRouteKind { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "default" => Ok(Self::Default), "vpc_subnet" => Ok(Self::VpcSubnet), "vpc_peering" => Ok(Self::VpcPeering), "custom" => Ok(Self::Custom), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for RouterRouteKind { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for RouterRouteKind { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for RouterRouteKind { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -9495,36 +9543,36 @@ pub mod types { } impl std::str::FromStr for SemverVersion { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new("^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\""); + return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\"".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for SemverVersion { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SemverVersion { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SemverVersion { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -9536,7 +9584,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -9582,32 +9632,32 @@ pub mod types { } impl std::str::FromStr for ServiceUsingCertificate { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "external_api" => Ok(Self::ExternalApi), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for ServiceUsingCertificate { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for ServiceUsingCertificate { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for ServiceUsingCertificate { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -9844,33 +9894,33 @@ pub mod types { } impl std::str::FromStr for SiloIdentityMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "saml_jit" => Ok(Self::SamlJit), "local_only" => Ok(Self::LocalOnly), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SiloIdentityMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SiloIdentityMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SiloIdentityMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -9969,34 +10019,34 @@ pub mod types { } impl std::str::FromStr for SiloRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SiloRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SiloRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SiloRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -10473,35 +10523,35 @@ pub mod types { } impl std::str::FromStr for SnapshotState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "creating" => Ok(Self::Creating), "ready" => Ok(Self::Ready), "faulted" => Ok(Self::Faulted), "destroyed" => Ok(Self::Destroyed), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SnapshotState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SnapshotState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SnapshotState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -10777,34 +10827,34 @@ pub mod types { } impl std::str::FromStr for SystemMetricName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "virtual_disk_space_provisioned" => Ok(Self::VirtualDiskSpaceProvisioned), "cpus_provisioned" => Ok(Self::CpusProvisioned), "ram_provisioned" => Ok(Self::RamProvisioned), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SystemMetricName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SystemMetricName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SystemMetricName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11039,8 +11089,8 @@ pub mod types { } impl std::str::FromStr for TimeseriesName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new( "(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*)", ) @@ -11050,29 +11100,30 @@ pub mod types { { return Err("doesn't match pattern \ \"(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*\ - )(_([a-z0-9]+))*)\""); + )(_([a-z0-9]+))*)\"" + .into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for TimeseriesName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for TimeseriesName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for TimeseriesName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11084,7 +11135,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -11384,33 +11437,33 @@ pub mod types { } impl std::str::FromStr for UpdateStatus { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "updating" => Ok(Self::Updating), "steady" => Ok(Self::Steady), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for UpdateStatus { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for UpdateStatus { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for UpdateStatus { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11628,8 +11681,8 @@ pub mod types { } impl std::str::FromStr for UpdateableComponentType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "bootloader_for_rot" => Ok(Self::BootloaderForRot), "bootloader_for_sp" => Ok(Self::BootloaderForSp), @@ -11643,28 +11696,28 @@ pub mod types { "helios_host_phase1" => Ok(Self::HeliosHostPhase1), "helios_host_phase2" => Ok(Self::HeliosHostPhase2), "host_omicron" => Ok(Self::HostOmicron), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for UpdateableComponentType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for UpdateableComponentType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for UpdateableComponentType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11945,33 +11998,33 @@ pub mod types { } impl std::str::FromStr for UserId { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 63usize { - return Err("longer than 63 characters"); + return Err("longer than 63 characters".into()); } - if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"") ; } + if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for UserId { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for UserId { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for UserId { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11983,7 +12036,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -12557,33 +12612,33 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleAction { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "allow" => Ok(Self::Allow), "deny" => Ok(Self::Deny), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleAction { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleAction { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleAction { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -12626,33 +12681,33 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleDirection { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "inbound" => Ok(Self::Inbound), "outbound" => Ok(Self::Outbound), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleDirection { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleDirection { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleDirection { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -12930,34 +12985,34 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleProtocol { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "TCP" => Ok(Self::Tcp), "UDP" => Ok(Self::Udp), "ICMP" => Ok(Self::Icmp), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleProtocol { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleProtocol { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleProtocol { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -13000,33 +13055,33 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleStatus { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "disabled" => Ok(Self::Disabled), "enabled" => Ok(Self::Enabled), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleStatus { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleStatus { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleStatus { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -13600,33 +13655,33 @@ pub mod types { } impl std::str::FromStr for VpcRouterKind { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "system" => Ok(Self::System), "custom" => Ok(Self::Custom), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcRouterKind { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcRouterKind { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcRouterKind { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -14075,6 +14130,7 @@ pub mod types { } } + /// Types for composing complex structures. pub mod builder { #[derive(Clone, Debug)] pub struct Baseboard { @@ -14127,8 +14183,8 @@ pub mod types { } impl std::convert::TryFrom for super::Baseboard { - type Error = String; - fn try_from(value: Baseboard) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Baseboard) -> Result { Ok(Self { part: value.part?, revision: value.revision?, @@ -14186,8 +14242,8 @@ pub mod types { } impl std::convert::TryFrom for super::Bindouble { - type Error = String; - fn try_from(value: Bindouble) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Bindouble) -> Result { Ok(Self { count: value.count?, range: value.range?, @@ -14243,8 +14299,8 @@ pub mod types { } impl std::convert::TryFrom for super::Binint64 { - type Error = String; - fn try_from(value: Binint64) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Binint64) -> Result { Ok(Self { count: value.count?, range: value.range?, @@ -14348,8 +14404,8 @@ pub mod types { } impl std::convert::TryFrom for super::Certificate { - type Error = String; - fn try_from(value: Certificate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Certificate) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -14449,8 +14505,8 @@ pub mod types { } impl std::convert::TryFrom for super::CertificateCreate { - type Error = String; - fn try_from(value: CertificateCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: CertificateCreate) -> Result { Ok(Self { cert: value.cert?, description: value.description?, @@ -14512,8 +14568,10 @@ pub mod types { } impl std::convert::TryFrom for super::CertificateResultsPage { - type Error = String; - fn try_from(value: CertificateResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: CertificateResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -14605,8 +14663,8 @@ pub mod types { } impl std::convert::TryFrom for super::ComponentUpdate { - type Error = String; - fn try_from(value: ComponentUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ComponentUpdate) -> Result { Ok(Self { component_type: value.component_type?, id: value.id?, @@ -14668,8 +14726,10 @@ pub mod types { } impl std::convert::TryFrom for super::ComponentUpdateResultsPage { - type Error = String; - fn try_from(value: ComponentUpdateResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: ComponentUpdateResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -14725,8 +14785,8 @@ pub mod types { } impl std::convert::TryFrom for super::Cumulativedouble { - type Error = String; - fn try_from(value: Cumulativedouble) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Cumulativedouble) -> Result { Ok(Self { start_time: value.start_time?, value: value.value?, @@ -14782,8 +14842,8 @@ pub mod types { } impl std::convert::TryFrom for super::Cumulativeint64 { - type Error = String; - fn try_from(value: Cumulativeint64) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Cumulativeint64) -> Result { Ok(Self { start_time: value.start_time?, value: value.value?, @@ -14839,8 +14899,8 @@ pub mod types { } impl std::convert::TryFrom for super::DerEncodedKeyPair { - type Error = String; - fn try_from(value: DerEncodedKeyPair) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DerEncodedKeyPair) -> Result { Ok(Self { private_key: value.private_key?, public_cert: value.public_cert?, @@ -14908,8 +14968,10 @@ pub mod types { } impl std::convert::TryFrom for super::DeviceAccessTokenRequest { - type Error = String; - fn try_from(value: DeviceAccessTokenRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: DeviceAccessTokenRequest, + ) -> Result { Ok(Self { client_id: value.client_id?, device_code: value.device_code?, @@ -14955,8 +15017,8 @@ pub mod types { } impl std::convert::TryFrom for super::DeviceAuthRequest { - type Error = String; - fn try_from(value: DeviceAuthRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DeviceAuthRequest) -> Result { Ok(Self { client_id: value.client_id?, }) @@ -14998,8 +15060,8 @@ pub mod types { } impl std::convert::TryFrom for super::DeviceAuthVerify { - type Error = String; - fn try_from(value: DeviceAuthVerify) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DeviceAuthVerify) -> Result { Ok(Self { user_code: value.user_code?, }) @@ -15173,8 +15235,8 @@ pub mod types { } impl std::convert::TryFrom for super::Disk { - type Error = String; - fn try_from(value: Disk) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Disk) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -15274,8 +15336,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskCreate { - type Error = String; - fn try_from(value: DiskCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskCreate) -> Result { Ok(Self { description: value.description?, disk_source: value.disk_source?, @@ -15323,8 +15385,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskIdentifier { - type Error = String; - fn try_from(value: DiskIdentifier) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskIdentifier) -> Result { Ok(Self { name: value.name? }) } } @@ -15364,8 +15426,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskPath { - type Error = String; - fn try_from(value: DiskPath) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskPath) -> Result { Ok(Self { disk: value.disk? }) } } @@ -15417,8 +15479,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskResultsPage { - type Error = String; - fn try_from(value: DiskResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -15474,8 +15536,8 @@ pub mod types { } impl std::convert::TryFrom for super::Distribution { - type Error = String; - fn try_from(value: Distribution) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Distribution) -> Result { Ok(Self { name: value.name?, version: value.version?, @@ -15543,8 +15605,8 @@ pub mod types { } impl std::convert::TryFrom for super::Error { - type Error = String; - fn try_from(value: Error) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Error) -> Result { Ok(Self { error_code: value.error_code?, message: value.message?, @@ -15602,8 +15664,8 @@ pub mod types { } impl std::convert::TryFrom for super::ExternalIp { - type Error = String; - fn try_from(value: ExternalIp) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ExternalIp) -> Result { Ok(Self { ip: value.ip?, kind: value.kind?, @@ -15659,8 +15721,10 @@ pub mod types { } impl std::convert::TryFrom for super::ExternalIpResultsPage { - type Error = String; - fn try_from(value: ExternalIpResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: ExternalIpResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -15728,8 +15792,8 @@ pub mod types { } impl std::convert::TryFrom for super::FieldSchema { - type Error = String; - fn try_from(value: FieldSchema) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: FieldSchema) -> Result { Ok(Self { name: value.name?, source: value.source?, @@ -15778,8 +15842,8 @@ pub mod types { } impl std::convert::TryFrom for super::FleetRolePolicy { - type Error = String; - fn try_from(value: FleetRolePolicy) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: FleetRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -15845,8 +15909,10 @@ pub mod types { } impl std::convert::TryFrom for super::FleetRoleRoleAssignment { - type Error = String; - fn try_from(value: FleetRoleRoleAssignment) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: FleetRoleRoleAssignment, + ) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -16012,8 +16078,8 @@ pub mod types { } impl std::convert::TryFrom for super::GlobalImage { - type Error = String; - fn try_from(value: GlobalImage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: GlobalImage) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -16123,8 +16189,8 @@ pub mod types { } impl std::convert::TryFrom for super::GlobalImageCreate { - type Error = String; - fn try_from(value: GlobalImageCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: GlobalImageCreate) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -16186,8 +16252,10 @@ pub mod types { } impl std::convert::TryFrom for super::GlobalImageResultsPage { - type Error = String; - fn try_from(value: GlobalImageResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: GlobalImageResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -16255,8 +16323,8 @@ pub mod types { } impl std::convert::TryFrom for super::Group { - type Error = String; - fn try_from(value: Group) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Group) -> Result { Ok(Self { display_name: value.display_name?, id: value.id?, @@ -16314,8 +16382,8 @@ pub mod types { } impl std::convert::TryFrom for super::GroupResultsPage { - type Error = String; - fn try_from(value: GroupResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: GroupResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -16383,8 +16451,8 @@ pub mod types { } impl std::convert::TryFrom for super::Histogramdouble { - type Error = String; - fn try_from(value: Histogramdouble) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Histogramdouble) -> Result { Ok(Self { bins: value.bins?, n_samples: value.n_samples?, @@ -16454,8 +16522,8 @@ pub mod types { } impl std::convert::TryFrom for super::Histogramint64 { - type Error = String; - fn try_from(value: Histogramint64) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Histogramint64) -> Result { Ok(Self { bins: value.bins?, n_samples: value.n_samples?, @@ -16561,8 +16629,8 @@ pub mod types { } impl std::convert::TryFrom for super::IdentityProvider { - type Error = String; - fn try_from(value: IdentityProvider) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IdentityProvider) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -16626,8 +16694,10 @@ pub mod types { } impl std::convert::TryFrom for super::IdentityProviderResultsPage { - type Error = String; - fn try_from(value: IdentityProviderResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: IdentityProviderResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -16791,8 +16861,8 @@ pub mod types { } impl std::convert::TryFrom for super::Image { - type Error = String; - fn try_from(value: Image) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Image) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -16890,8 +16960,8 @@ pub mod types { } impl std::convert::TryFrom for super::ImageCreate { - type Error = String; - fn try_from(value: ImageCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ImageCreate) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -16951,8 +17021,8 @@ pub mod types { } impl std::convert::TryFrom for super::ImageResultsPage { - type Error = String; - fn try_from(value: ImageResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ImageResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -17121,8 +17191,8 @@ pub mod types { } impl std::convert::TryFrom for super::Instance { - type Error = String; - fn try_from(value: Instance) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Instance) -> Result { Ok(Self { description: value.description?, hostname: value.hostname?, @@ -17295,8 +17365,8 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceCreate { - type Error = String; - fn try_from(value: InstanceCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: InstanceCreate) -> Result { Ok(Self { description: value.description?, disks: value.disks?, @@ -17356,8 +17426,8 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceMigrate { - type Error = String; - fn try_from(value: InstanceMigrate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: InstanceMigrate) -> Result { Ok(Self { dst_sled_id: value.dst_sled_id?, }) @@ -17411,8 +17481,8 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceResultsPage { - type Error = String; - fn try_from(value: InstanceResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: InstanceResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -17471,8 +17541,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceSerialConsoleData { - type Error = String; - fn try_from(value: InstanceSerialConsoleData) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceSerialConsoleData, + ) -> Result { Ok(Self { data: value.data?, last_byte_offset: value.last_byte_offset?, @@ -17564,8 +17636,8 @@ pub mod types { } impl std::convert::TryFrom for super::IpPool { - type Error = String; - fn try_from(value: IpPool) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IpPool) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -17627,8 +17699,8 @@ pub mod types { } impl std::convert::TryFrom for super::IpPoolCreate { - type Error = String; - fn try_from(value: IpPoolCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IpPoolCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -17696,8 +17768,8 @@ pub mod types { } impl std::convert::TryFrom for super::IpPoolRange { - type Error = String; - fn try_from(value: IpPoolRange) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IpPoolRange) -> Result { Ok(Self { id: value.id?, range: value.range?, @@ -17755,8 +17827,10 @@ pub mod types { } impl std::convert::TryFrom for super::IpPoolRangeResultsPage { - type Error = String; - fn try_from(value: IpPoolRangeResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: IpPoolRangeResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -17812,8 +17886,8 @@ pub mod types { } impl std::convert::TryFrom for super::IpPoolResultsPage { - type Error = String; - fn try_from(value: IpPoolResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IpPoolResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -17869,8 +17943,8 @@ pub mod types { } impl std::convert::TryFrom for super::IpPoolUpdate { - type Error = String; - fn try_from(value: IpPoolUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: IpPoolUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -17926,8 +18000,8 @@ pub mod types { } impl std::convert::TryFrom for super::Ipv4Range { - type Error = String; - fn try_from(value: Ipv4Range) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Ipv4Range) -> Result { Ok(Self { first: value.first?, last: value.last?, @@ -17983,8 +18057,8 @@ pub mod types { } impl std::convert::TryFrom for super::Ipv6Range { - type Error = String; - fn try_from(value: Ipv6Range) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Ipv6Range) -> Result { Ok(Self { first: value.first?, last: value.last?, @@ -18040,8 +18114,8 @@ pub mod types { } impl std::convert::TryFrom for super::Measurement { - type Error = String; - fn try_from(value: Measurement) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Measurement) -> Result { Ok(Self { datum: value.datum?, timestamp: value.timestamp?, @@ -18097,8 +18171,10 @@ pub mod types { } impl std::convert::TryFrom for super::MeasurementResultsPage { - type Error = String; - fn try_from(value: MeasurementResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: MeasurementResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -18262,8 +18338,8 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterface { - type Error = String; - fn try_from(value: NetworkInterface) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: NetworkInterface) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -18373,8 +18449,10 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterfaceCreate { - type Error = String; - fn try_from(value: NetworkInterfaceCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceCreate, + ) -> Result { Ok(Self { description: value.description?, ip: value.ip?, @@ -18436,8 +18514,10 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterfaceResultsPage { - type Error = String; - fn try_from(value: NetworkInterfaceResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -18505,8 +18585,10 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterfaceUpdate { - type Error = String; - fn try_from(value: NetworkInterfaceUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceUpdate, + ) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -18600,8 +18682,8 @@ pub mod types { } impl std::convert::TryFrom for super::Organization { - type Error = String; - fn try_from(value: Organization) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Organization) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -18663,8 +18745,8 @@ pub mod types { } impl std::convert::TryFrom for super::OrganizationCreate { - type Error = String; - fn try_from(value: OrganizationCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: OrganizationCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -18720,8 +18802,10 @@ pub mod types { } impl std::convert::TryFrom for super::OrganizationResultsPage { - type Error = String; - fn try_from(value: OrganizationResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -18768,8 +18852,10 @@ pub mod types { } impl std::convert::TryFrom for super::OrganizationRolePolicy { - type Error = String; - fn try_from(value: OrganizationRolePolicy) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationRolePolicy, + ) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -18837,8 +18923,10 @@ pub mod types { impl std::convert::TryFrom for super::OrganizationRoleRoleAssignment { - type Error = String; - fn try_from(value: OrganizationRoleRoleAssignment) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: OrganizationRoleRoleAssignment, + ) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -18896,8 +18984,8 @@ pub mod types { } impl std::convert::TryFrom for super::OrganizationUpdate { - type Error = String; - fn try_from(value: OrganizationUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: OrganizationUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -19025,8 +19113,8 @@ pub mod types { } impl std::convert::TryFrom for super::PhysicalDisk { - type Error = String; - fn try_from(value: PhysicalDisk) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: PhysicalDisk) -> Result { Ok(Self { disk_type: value.disk_type?, id: value.id?, @@ -19094,8 +19182,10 @@ pub mod types { } impl std::convert::TryFrom for super::PhysicalDiskResultsPage { - type Error = String; - fn try_from(value: PhysicalDiskResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: PhysicalDiskResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -19199,8 +19289,8 @@ pub mod types { } impl std::convert::TryFrom for super::Project { - type Error = String; - fn try_from(value: Project) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Project) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -19264,8 +19354,8 @@ pub mod types { } impl std::convert::TryFrom for super::ProjectCreate { - type Error = String; - fn try_from(value: ProjectCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ProjectCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -19321,8 +19411,8 @@ pub mod types { } impl std::convert::TryFrom for super::ProjectResultsPage { - type Error = String; - fn try_from(value: ProjectResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ProjectResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -19369,8 +19459,8 @@ pub mod types { } impl std::convert::TryFrom for super::ProjectRolePolicy { - type Error = String; - fn try_from(value: ProjectRolePolicy) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ProjectRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -19436,8 +19526,10 @@ pub mod types { } impl std::convert::TryFrom for super::ProjectRoleRoleAssignment { - type Error = String; - fn try_from(value: ProjectRoleRoleAssignment) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: ProjectRoleRoleAssignment, + ) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -19495,8 +19587,8 @@ pub mod types { } impl std::convert::TryFrom for super::ProjectUpdate { - type Error = String; - fn try_from(value: ProjectUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: ProjectUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -19564,8 +19656,8 @@ pub mod types { } impl std::convert::TryFrom for super::Rack { - type Error = String; - fn try_from(value: Rack) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Rack) -> Result { Ok(Self { id: value.id?, time_created: value.time_created?, @@ -19623,8 +19715,8 @@ pub mod types { } impl std::convert::TryFrom for super::RackResultsPage { - type Error = String; - fn try_from(value: RackResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: RackResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -19680,8 +19772,8 @@ pub mod types { } impl std::convert::TryFrom for super::Role { - type Error = String; - fn try_from(value: Role) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Role) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -19737,8 +19829,8 @@ pub mod types { } impl std::convert::TryFrom for super::RoleResultsPage { - type Error = String; - fn try_from(value: RoleResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: RoleResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -19878,8 +19970,8 @@ pub mod types { } impl std::convert::TryFrom for super::RouterRoute { - type Error = String; - fn try_from(value: RouterRoute) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: RouterRoute) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -19973,8 +20065,10 @@ pub mod types { } impl std::convert::TryFrom for super::RouterRouteCreateParams { - type Error = String; - fn try_from(value: RouterRouteCreateParams) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteCreateParams, + ) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -20034,8 +20128,10 @@ pub mod types { } impl std::convert::TryFrom for super::RouterRouteResultsPage { - type Error = String; - fn try_from(value: RouterRouteResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -20115,8 +20211,10 @@ pub mod types { } impl std::convert::TryFrom for super::RouterRouteUpdateParams { - type Error = String; - fn try_from(value: RouterRouteUpdateParams) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: RouterRouteUpdateParams, + ) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -20176,8 +20274,8 @@ pub mod types { } impl std::convert::TryFrom for super::Saga { - type Error = String; - fn try_from(value: Saga) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Saga) -> Result { Ok(Self { id: value.id?, state: value.state?, @@ -20233,8 +20331,8 @@ pub mod types { } impl std::convert::TryFrom for super::SagaResultsPage { - type Error = String; - fn try_from(value: SagaResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SagaResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -20403,8 +20501,10 @@ pub mod types { } impl std::convert::TryFrom for super::SamlIdentityProvider { - type Error = String; - fn try_from(value: SamlIdentityProvider) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: SamlIdentityProvider, + ) -> Result { Ok(Self { acs_url: value.acs_url?, description: value.description?, @@ -20587,8 +20687,10 @@ pub mod types { } impl std::convert::TryFrom for super::SamlIdentityProviderCreate { - type Error = String; - fn try_from(value: SamlIdentityProviderCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: SamlIdentityProviderCreate, + ) -> Result { Ok(Self { acs_url: value.acs_url?, description: value.description?, @@ -20720,8 +20822,8 @@ pub mod types { } impl std::convert::TryFrom for super::Silo { - type Error = String; - fn try_from(value: Silo) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Silo) -> Result { Ok(Self { description: value.description?, discoverable: value.discoverable?, @@ -20826,8 +20928,8 @@ pub mod types { } impl std::convert::TryFrom for super::SiloCreate { - type Error = String; - fn try_from(value: SiloCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SiloCreate) -> Result { Ok(Self { admin_group_name: value.admin_group_name?, description: value.description?, @@ -20889,8 +20991,8 @@ pub mod types { } impl std::convert::TryFrom for super::SiloResultsPage { - type Error = String; - fn try_from(value: SiloResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SiloResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -20937,8 +21039,8 @@ pub mod types { } impl std::convert::TryFrom for super::SiloRolePolicy { - type Error = String; - fn try_from(value: SiloRolePolicy) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SiloRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -21004,8 +21106,10 @@ pub mod types { } impl std::convert::TryFrom for super::SiloRoleRoleAssignment { - type Error = String; - fn try_from(value: SiloRoleRoleAssignment) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: SiloRoleRoleAssignment, + ) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -21099,8 +21203,8 @@ pub mod types { } impl std::convert::TryFrom for super::Sled { - type Error = String; - fn try_from(value: Sled) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Sled) -> Result { Ok(Self { baseboard: value.baseboard?, id: value.id?, @@ -21162,8 +21266,8 @@ pub mod types { } impl std::convert::TryFrom for super::SledResultsPage { - type Error = String; - fn try_from(value: SledResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SledResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -21303,8 +21407,8 @@ pub mod types { } impl std::convert::TryFrom for super::Snapshot { - type Error = String; - fn try_from(value: Snapshot) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Snapshot) -> Result { Ok(Self { description: value.description?, disk_id: value.disk_id?, @@ -21386,8 +21490,8 @@ pub mod types { } impl std::convert::TryFrom for super::SnapshotCreate { - type Error = String; - fn try_from(value: SnapshotCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SnapshotCreate) -> Result { Ok(Self { description: value.description?, disk: value.disk?, @@ -21445,8 +21549,8 @@ pub mod types { } impl std::convert::TryFrom for super::SnapshotResultsPage { - type Error = String; - fn try_from(value: SnapshotResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SnapshotResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -21490,8 +21594,8 @@ pub mod types { } impl std::convert::TryFrom for super::SpoofLoginBody { - type Error = String; - fn try_from(value: SpoofLoginBody) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SpoofLoginBody) -> Result { Ok(Self { username: value.username?, }) @@ -21605,8 +21709,8 @@ pub mod types { } impl std::convert::TryFrom for super::SshKey { - type Error = String; - fn try_from(value: SshKey) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SshKey) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -21684,8 +21788,8 @@ pub mod types { } impl std::convert::TryFrom for super::SshKeyCreate { - type Error = String; - fn try_from(value: SshKeyCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SshKeyCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -21743,8 +21847,8 @@ pub mod types { } impl std::convert::TryFrom for super::SshKeyResultsPage { - type Error = String; - fn try_from(value: SshKeyResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SshKeyResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -21824,8 +21928,8 @@ pub mod types { } impl std::convert::TryFrom for super::SystemUpdate { - type Error = String; - fn try_from(value: SystemUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SystemUpdate) -> Result { Ok(Self { id: value.id?, time_created: value.time_created?, @@ -21885,8 +21989,10 @@ pub mod types { } impl std::convert::TryFrom for super::SystemUpdateResultsPage { - type Error = String; - fn try_from(value: SystemUpdateResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: SystemUpdateResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -21930,8 +22036,8 @@ pub mod types { } impl std::convert::TryFrom for super::SystemUpdateStart { - type Error = String; - fn try_from(value: SystemUpdateStart) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SystemUpdateStart) -> Result { Ok(Self { version: value.version?, }) @@ -21985,8 +22091,8 @@ pub mod types { } impl std::convert::TryFrom for super::SystemVersion { - type Error = String; - fn try_from(value: SystemVersion) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: SystemVersion) -> Result { Ok(Self { status: value.status?, version_range: value.version_range?, @@ -22066,8 +22172,8 @@ pub mod types { } impl std::convert::TryFrom for super::TimeseriesSchema { - type Error = String; - fn try_from(value: TimeseriesSchema) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: TimeseriesSchema) -> Result { Ok(Self { created: value.created?, datum_type: value.datum_type?, @@ -22127,8 +22233,10 @@ pub mod types { } impl std::convert::TryFrom for super::TimeseriesSchemaResultsPage { - type Error = String; - fn try_from(value: TimeseriesSchemaResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: TimeseriesSchemaResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -22220,8 +22328,8 @@ pub mod types { } impl std::convert::TryFrom for super::UpdateDeployment { - type Error = String; - fn try_from(value: UpdateDeployment) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UpdateDeployment) -> Result { Ok(Self { id: value.id?, status: value.status?, @@ -22283,8 +22391,10 @@ pub mod types { } impl std::convert::TryFrom for super::UpdateDeploymentResultsPage { - type Error = String; - fn try_from(value: UpdateDeploymentResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateDeploymentResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -22412,8 +22522,8 @@ pub mod types { } impl std::convert::TryFrom for super::UpdateableComponent { - type Error = String; - fn try_from(value: UpdateableComponent) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UpdateableComponent) -> Result { Ok(Self { component_type: value.component_type?, device_id: value.device_id?, @@ -22483,8 +22593,10 @@ pub mod types { impl std::convert::TryFrom for super::UpdateableComponentResultsPage { - type Error = String; - fn try_from(value: UpdateableComponentResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: UpdateableComponentResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -22552,8 +22664,8 @@ pub mod types { } impl std::convert::TryFrom for super::User { - type Error = String; - fn try_from(value: User) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: User) -> Result { Ok(Self { display_name: value.display_name?, id: value.id?, @@ -22647,8 +22759,8 @@ pub mod types { } impl std::convert::TryFrom for super::UserBuiltin { - type Error = String; - fn try_from(value: UserBuiltin) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UserBuiltin) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -22710,8 +22822,10 @@ pub mod types { } impl std::convert::TryFrom for super::UserBuiltinResultsPage { - type Error = String; - fn try_from(value: UserBuiltinResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: UserBuiltinResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -22767,8 +22881,8 @@ pub mod types { } impl std::convert::TryFrom for super::UserCreate { - type Error = String; - fn try_from(value: UserCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UserCreate) -> Result { Ok(Self { external_id: value.external_id?, password: value.password?, @@ -22824,8 +22938,8 @@ pub mod types { } impl std::convert::TryFrom for super::UserResultsPage { - type Error = String; - fn try_from(value: UserResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: UserResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -22881,8 +22995,10 @@ pub mod types { } impl std::convert::TryFrom for super::UsernamePasswordCredentials { - type Error = String; - fn try_from(value: UsernamePasswordCredentials) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: UsernamePasswordCredentials, + ) -> Result { Ok(Self { password: value.password?, username: value.username?, @@ -22938,8 +23054,8 @@ pub mod types { } impl std::convert::TryFrom for super::VersionRange { - type Error = String; - fn try_from(value: VersionRange) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VersionRange) -> Result { Ok(Self { high: value.high?, low: value.low?, @@ -23082,8 +23198,8 @@ pub mod types { } impl std::convert::TryFrom for super::Vpc { - type Error = String; - fn try_from(value: Vpc) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Vpc) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, @@ -23177,8 +23293,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcCreate { - type Error = String; - fn try_from(value: VpcCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcCreate) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, @@ -23358,8 +23474,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcFirewallRule { - type Error = String; - fn try_from(value: VpcFirewallRule) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcFirewallRule) -> Result { Ok(Self { action: value.action?, description: value.description?, @@ -23447,8 +23563,10 @@ pub mod types { } impl std::convert::TryFrom for super::VpcFirewallRuleFilter { - type Error = String; - fn try_from(value: VpcFirewallRuleFilter) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleFilter, + ) -> Result { Ok(Self { hosts: value.hosts?, ports: value.ports?, @@ -23578,8 +23696,10 @@ pub mod types { } impl std::convert::TryFrom for super::VpcFirewallRuleUpdate { - type Error = String; - fn try_from(value: VpcFirewallRuleUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleUpdate, + ) -> Result { Ok(Self { action: value.action?, description: value.description?, @@ -23635,8 +23755,10 @@ pub mod types { } impl std::convert::TryFrom for super::VpcFirewallRuleUpdateParams { - type Error = String; - fn try_from(value: VpcFirewallRuleUpdateParams) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: VpcFirewallRuleUpdateParams, + ) -> Result { Ok(Self { rules: value.rules?, }) @@ -23678,8 +23800,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcFirewallRules { - type Error = String; - fn try_from(value: VpcFirewallRules) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcFirewallRules) -> Result { Ok(Self { rules: value.rules?, }) @@ -23733,8 +23855,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcResultsPage { - type Error = String; - fn try_from(value: VpcResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -23850,8 +23972,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcRouter { - type Error = String; - fn try_from(value: VpcRouter) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcRouter) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -23917,8 +24039,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcRouterCreate { - type Error = String; - fn try_from(value: VpcRouterCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcRouterCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -23974,8 +24096,10 @@ pub mod types { } impl std::convert::TryFrom for super::VpcRouterResultsPage { - type Error = String; - fn try_from(value: VpcRouterResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: VpcRouterResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -24031,8 +24155,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcRouterUpdate { - type Error = String; - fn try_from(value: VpcRouterUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcRouterUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -24160,8 +24284,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcSubnet { - type Error = String; - fn try_from(value: VpcSubnet) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcSubnet) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -24253,8 +24377,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcSubnetCreate { - type Error = String; - fn try_from(value: VpcSubnetCreate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcSubnetCreate) -> Result { Ok(Self { description: value.description?, ipv4_block: value.ipv4_block?, @@ -24314,8 +24438,10 @@ pub mod types { } impl std::convert::TryFrom for super::VpcSubnetResultsPage { - type Error = String; - fn try_from(value: VpcSubnetResultsPage) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: VpcSubnetResultsPage, + ) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -24371,8 +24497,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcSubnetUpdate { - type Error = String; - fn try_from(value: VpcSubnetUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcSubnetUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -24440,8 +24566,8 @@ pub mod types { } impl std::convert::TryFrom for super::VpcUpdate { - type Error = String; - fn try_from(value: VpcUpdate) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: VpcUpdate) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, @@ -24461,6 +24587,7 @@ pub mod types { } } + /// Generation of default values for serde. pub mod defaults { pub(super) fn default_bool() -> bool { V diff --git a/progenitor-impl/tests/output/src/nexus_positional.rs b/progenitor-impl/tests/output/src/nexus_positional.rs index 673331d..f70690e 100644 --- a/progenitor-impl/tests/output/src/nexus_positional.rs +++ b/progenitor-impl/tests/output/src/nexus_positional.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///Describes properties that should uniquely identify a Gimlet. /// ///
JSON schema @@ -396,10 +426,10 @@ pub mod types { } impl std::convert::TryFrom for BlockSize { - type Error = &'static str; - fn try_from(value: i64) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: i64) -> Result { if ![512_i64, 2048_i64, 4096_i64].contains(&value) { - Err("invalid value") + Err("invalid value".into()) } else { Ok(Self(value)) } @@ -1202,8 +1232,8 @@ pub mod types { } impl std::str::FromStr for DatumType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "bool" => Ok(Self::Bool), "i64" => Ok(Self::I64), @@ -1214,28 +1244,28 @@ pub mod types { "cumulative_f64" => Ok(Self::CumulativeF64), "histogram_i64" => Ok(Self::HistogramI64), "histogram_f64" => Ok(Self::HistogramF64), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for DatumType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for DatumType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for DatumType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -1681,8 +1711,8 @@ pub mod types { } impl std::str::FromStr for DiskMetricName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "activated" => Ok(Self::Activated), "flush" => Ok(Self::Flush), @@ -1690,28 +1720,28 @@ pub mod types { "read_bytes" => Ok(Self::ReadBytes), "write" => Ok(Self::Write), "write_bytes" => Ok(Self::WriteBytes), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for DiskMetricName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for DiskMetricName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for DiskMetricName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -2378,33 +2408,33 @@ pub mod types { } impl std::str::FromStr for FieldSource { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "target" => Ok(Self::Target), "metric" => Ok(Self::Metric), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for FieldSource { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for FieldSource { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for FieldSource { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -2461,36 +2491,36 @@ pub mod types { } impl std::str::FromStr for FieldType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "string" => Ok(Self::String), "i64" => Ok(Self::I64), "ip_addr" => Ok(Self::IpAddr), "uuid" => Ok(Self::Uuid), "bool" => Ok(Self::Bool), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for FieldType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for FieldType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for FieldType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -2537,34 +2567,34 @@ pub mod types { } impl std::str::FromStr for FleetRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for FleetRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for FleetRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for FleetRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -3276,32 +3306,32 @@ pub mod types { } impl std::str::FromStr for IdSortMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "id_ascending" => Ok(Self::IdAscending), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IdSortMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IdSortMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IdSortMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -3472,32 +3502,32 @@ pub mod types { } impl std::str::FromStr for IdentityProviderType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "saml" => Ok(Self::Saml), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IdentityProviderType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IdentityProviderType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IdentityProviderType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -3541,33 +3571,33 @@ pub mod types { } impl std::str::FromStr for IdentityType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "silo_user" => Ok(Self::SiloUser), "silo_group" => Ok(Self::SiloGroup), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IdentityType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IdentityType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IdentityType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -4754,8 +4784,8 @@ pub mod types { } impl std::str::FromStr for InstanceState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "creating" => Ok(Self::Creating), "starting" => Ok(Self::Starting), @@ -4767,28 +4797,28 @@ pub mod types { "repairing" => Ok(Self::Repairing), "failed" => Ok(Self::Failed), "destroyed" => Ok(Self::Destroyed), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for InstanceState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for InstanceState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for InstanceState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -4832,33 +4862,33 @@ pub mod types { } impl std::str::FromStr for IpKind { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "ephemeral" => Ok(Self::Ephemeral), "floating" => Ok(Self::Floating), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for IpKind { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IpKind { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IpKind { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -4904,35 +4934,35 @@ pub mod types { } impl std::str::FromStr for IpNet { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if let Ok(v) = value.parse() { Ok(Self::V4(v)) } else if let Ok(v) = value.parse() { Ok(Self::V6(v)) } else { - Err("string conversion failed for all variants") + Err("string conversion failed for all variants".into()) } } } impl std::convert::TryFrom<&str> for IpNet { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for IpNet { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for IpNet { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5333,8 +5363,8 @@ pub mod types { } impl std::str::FromStr for Ipv4Net { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new( "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ @@ -5347,29 +5377,30 @@ pub mod types { return Err("doesn't match pattern \ \"^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.\ ){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/\ - ([8-9]|1[0-9]|2[0-9]|3[0-2])$\""); + ([8-9]|1[0-9]|2[0-9]|3[0-2])$\"" + .into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Ipv4Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Ipv4Net { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Ipv4Net { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5381,7 +5412,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -5466,8 +5499,8 @@ pub mod types { } impl std::str::FromStr for Ipv6Net { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new( "^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,\ 4}:){1,6}:)\\/([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$", @@ -5479,29 +5512,30 @@ pub mod types { return Err("doesn't match pattern \ \"^([fF][dD])[0-9a-fA-F]{2}:(([0-9a-fA-F]{1,4}:){6}[0-9a-fA-F]{1,\ 4}|([0-9a-fA-F]{1,4}:){1,6}:)\\/\ - ([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$\""); + ([1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8])$\"" + .into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Ipv6Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Ipv6Net { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Ipv6Net { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5513,7 +5547,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -5600,42 +5636,42 @@ pub mod types { } impl std::str::FromStr for L4PortRange { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 11usize { - return Err("longer than 11 characters"); + return Err("longer than 11 characters".into()); } if value.len() < 1usize { - return Err("shorter than 1 characters"); + return Err("shorter than 1 characters".into()); } if regress::Regex::new("^[0-9]{1,5}(-[0-9]{1,5})?$") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"^[0-9]{1,5}(-[0-9]{1,5})?$\""); + return Err("doesn't match pattern \"^[0-9]{1,5}(-[0-9]{1,5})?$\"".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for L4PortRange { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for L4PortRange { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for L4PortRange { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5647,7 +5683,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -5691,42 +5729,44 @@ pub mod types { } impl std::str::FromStr for MacAddr { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 17usize { - return Err("longer than 17 characters"); + return Err("longer than 17 characters".into()); } if value.len() < 17usize { - return Err("shorter than 17 characters"); + return Err("shorter than 17 characters".into()); } if regress::Regex::new("^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$\""); + return Err( + "doesn't match pattern \"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$\"".into(), + ); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for MacAddr { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for MacAddr { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for MacAddr { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5738,7 +5778,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -5868,33 +5910,33 @@ pub mod types { } impl std::str::FromStr for Name { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 63usize { - return Err("longer than 63 characters"); + return Err("longer than 63 characters".into()); } - if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"") ; } + if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Name { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Name { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Name { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -5906,7 +5948,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -5952,35 +5996,35 @@ pub mod types { } impl std::str::FromStr for NameOrId { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if let Ok(v) = value.parse() { Ok(Self::Id(v)) } else if let Ok(v) = value.parse() { Ok(Self::Name(v)) } else { - Err("string conversion failed for all variants") + Err("string conversion failed for all variants".into()) } } } impl std::convert::TryFrom<&str> for NameOrId { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for NameOrId { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for NameOrId { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6070,34 +6114,34 @@ pub mod types { } impl std::str::FromStr for NameOrIdSortMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), "name_descending" => Ok(Self::NameDescending), "id_ascending" => Ok(Self::IdAscending), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for NameOrIdSortMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for NameOrIdSortMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for NameOrIdSortMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6146,32 +6190,32 @@ pub mod types { } impl std::str::FromStr for NameSortMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for NameSortMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for NameSortMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for NameSortMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6740,34 +6784,34 @@ pub mod types { } impl std::str::FromStr for OrganizationRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for OrganizationRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for OrganizationRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for OrganizationRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6942,32 +6986,32 @@ pub mod types { } impl std::str::FromStr for Password { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 512usize { - return Err("longer than 512 characters"); + return Err("longer than 512 characters".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for Password { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for Password { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for Password { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -6979,7 +7023,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -7148,33 +7194,33 @@ pub mod types { } impl std::str::FromStr for PhysicalDiskType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "internal" => Ok(Self::Internal), "external" => Ok(Self::External), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for PhysicalDiskType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for PhysicalDiskType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for PhysicalDiskType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -7379,34 +7425,34 @@ pub mod types { } impl std::str::FromStr for ProjectRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for ProjectRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for ProjectRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for ProjectRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -7714,39 +7760,39 @@ pub mod types { } impl std::str::FromStr for RoleName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 63usize { - return Err("longer than 63 characters"); + return Err("longer than 63 characters".into()); } if regress::Regex::new("[a-z-]+\\.[a-z-]+") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"[a-z-]+\\.[a-z-]+\""); + return Err("doesn't match pattern \"[a-z-]+\\.[a-z-]+\"".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for RoleName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for RoleName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for RoleName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -7758,7 +7804,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -8324,35 +8372,35 @@ pub mod types { } impl std::str::FromStr for RouterRouteKind { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "default" => Ok(Self::Default), "vpc_subnet" => Ok(Self::VpcSubnet), "vpc_peering" => Ok(Self::VpcPeering), "custom" => Ok(Self::Custom), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for RouterRouteKind { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for RouterRouteKind { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for RouterRouteKind { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -8997,36 +9045,36 @@ pub mod types { } impl std::str::FromStr for SemverVersion { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new("^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$") .unwrap() .find(value) .is_none() { - return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\""); + return Err("doesn't match pattern \"^\\d+\\.\\d+\\.\\d+([\\-\\+].+)?$\"".into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for SemverVersion { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SemverVersion { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SemverVersion { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -9038,7 +9086,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -9084,32 +9134,32 @@ pub mod types { } impl std::str::FromStr for ServiceUsingCertificate { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "external_api" => Ok(Self::ExternalApi), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for ServiceUsingCertificate { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for ServiceUsingCertificate { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for ServiceUsingCertificate { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -9334,33 +9384,33 @@ pub mod types { } impl std::str::FromStr for SiloIdentityMode { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "saml_jit" => Ok(Self::SamlJit), "local_only" => Ok(Self::LocalOnly), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SiloIdentityMode { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SiloIdentityMode { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SiloIdentityMode { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -9453,34 +9503,34 @@ pub mod types { } impl std::str::FromStr for SiloRole { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), "viewer" => Ok(Self::Viewer), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SiloRole { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SiloRole { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SiloRole { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -9915,35 +9965,35 @@ pub mod types { } impl std::str::FromStr for SnapshotState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "creating" => Ok(Self::Creating), "ready" => Ok(Self::Ready), "faulted" => Ok(Self::Faulted), "destroyed" => Ok(Self::Destroyed), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SnapshotState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SnapshotState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SnapshotState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -10195,34 +10245,34 @@ pub mod types { } impl std::str::FromStr for SystemMetricName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "virtual_disk_space_provisioned" => Ok(Self::VirtualDiskSpaceProvisioned), "cpus_provisioned" => Ok(Self::CpusProvisioned), "ram_provisioned" => Ok(Self::RamProvisioned), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for SystemMetricName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for SystemMetricName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for SystemMetricName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -10433,8 +10483,8 @@ pub mod types { } impl std::str::FromStr for TimeseriesName { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if regress::Regex::new( "(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*)", ) @@ -10444,29 +10494,30 @@ pub mod types { { return Err("doesn't match pattern \ \"(([a-z]+[a-z0-9]*)(_([a-z0-9]+))*):(([a-z]+[a-z0-9]*\ - )(_([a-z0-9]+))*)\""); + )(_([a-z0-9]+))*)\"" + .into()); } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for TimeseriesName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for TimeseriesName { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for TimeseriesName { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -10478,7 +10529,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -10754,33 +10807,33 @@ pub mod types { } impl std::str::FromStr for UpdateStatus { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "updating" => Ok(Self::Updating), "steady" => Ok(Self::Steady), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for UpdateStatus { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for UpdateStatus { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for UpdateStatus { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -10986,8 +11039,8 @@ pub mod types { } impl std::str::FromStr for UpdateableComponentType { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "bootloader_for_rot" => Ok(Self::BootloaderForRot), "bootloader_for_sp" => Ok(Self::BootloaderForSp), @@ -11001,28 +11054,28 @@ pub mod types { "helios_host_phase1" => Ok(Self::HeliosHostPhase1), "helios_host_phase2" => Ok(Self::HeliosHostPhase2), "host_omicron" => Ok(Self::HostOmicron), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for UpdateableComponentType { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for UpdateableComponentType { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for UpdateableComponentType { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11279,33 +11332,33 @@ pub mod types { } impl std::str::FromStr for UserId { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { if value.len() > 63usize { - return Err("longer than 63 characters"); + return Err("longer than 63 characters".into()); } - if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"") ; } + if regress :: Regex :: new ("^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(?![0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)^[a-z][a-z0-9-]*[a-zA-Z0-9]$\"" . into ()) ; } Ok(Self(value.to_string())) } } impl std::convert::TryFrom<&str> for UserId { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for UserId { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for UserId { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11317,7 +11370,9 @@ pub mod types { { String::deserialize(deserializer)? .parse() - .map_err(|e: &'static str| ::custom(e.to_string())) + .map_err(|e: self::error::ConversionError| { + ::custom(e.to_string()) + }) } } @@ -11855,33 +11910,33 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleAction { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "allow" => Ok(Self::Allow), "deny" => Ok(Self::Deny), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleAction { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleAction { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleAction { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -11924,33 +11979,33 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleDirection { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "inbound" => Ok(Self::Inbound), "outbound" => Ok(Self::Outbound), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleDirection { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleDirection { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleDirection { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -12222,34 +12277,34 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleProtocol { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "TCP" => Ok(Self::Tcp), "UDP" => Ok(Self::Udp), "ICMP" => Ok(Self::Icmp), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleProtocol { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleProtocol { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleProtocol { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -12292,33 +12347,33 @@ pub mod types { } impl std::str::FromStr for VpcFirewallRuleStatus { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "disabled" => Ok(Self::Disabled), "enabled" => Ok(Self::Enabled), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcFirewallRuleStatus { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcFirewallRuleStatus { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcFirewallRuleStatus { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -12856,33 +12911,33 @@ pub mod types { } impl std::str::FromStr for VpcRouterKind { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "system" => Ok(Self::System), "custom" => Ok(Self::Custom), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for VpcRouterKind { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for VpcRouterKind { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for VpcRouterKind { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -13289,6 +13344,7 @@ pub mod types { } } + /// Generation of default values for serde. pub mod defaults { pub(super) fn default_bool() -> bool { V diff --git a/progenitor-impl/tests/output/src/param_collision_builder.rs b/progenitor-impl/tests/output/src/param_collision_builder.rs index bac364c..153dc6e 100644 --- a/progenitor-impl/tests/output/src/param_collision_builder.rs +++ b/progenitor-impl/tests/output/src/param_collision_builder.rs @@ -8,6 +8,35 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } } #[derive(Clone, Debug)] diff --git a/progenitor-impl/tests/output/src/param_collision_builder_tagged.rs b/progenitor-impl/tests/output/src/param_collision_builder_tagged.rs index 6483b4b..b8b2a6f 100644 --- a/progenitor-impl/tests/output/src/param_collision_builder_tagged.rs +++ b/progenitor-impl/tests/output/src/param_collision_builder_tagged.rs @@ -8,6 +8,35 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } } #[derive(Clone, Debug)] diff --git a/progenitor-impl/tests/output/src/param_collision_positional.rs b/progenitor-impl/tests/output/src/param_collision_positional.rs index aa439b0..ff4832b 100644 --- a/progenitor-impl/tests/output/src/param_collision_positional.rs +++ b/progenitor-impl/tests/output/src/param_collision_positional.rs @@ -8,6 +8,35 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } } #[derive(Clone, Debug)] diff --git a/progenitor-impl/tests/output/src/param_overrides_builder.rs b/progenitor-impl/tests/output/src/param_overrides_builder.rs index 6c96c23..6cc3c2b 100644 --- a/progenitor-impl/tests/output/src/param_overrides_builder.rs +++ b/progenitor-impl/tests/output/src/param_overrides_builder.rs @@ -8,6 +8,35 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } } #[derive(Clone, Debug)] diff --git a/progenitor-impl/tests/output/src/param_overrides_builder_tagged.rs b/progenitor-impl/tests/output/src/param_overrides_builder_tagged.rs index d6fff49..340fb37 100644 --- a/progenitor-impl/tests/output/src/param_overrides_builder_tagged.rs +++ b/progenitor-impl/tests/output/src/param_overrides_builder_tagged.rs @@ -8,6 +8,35 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } } #[derive(Clone, Debug)] diff --git a/progenitor-impl/tests/output/src/param_overrides_positional.rs b/progenitor-impl/tests/output/src/param_overrides_positional.rs index 8ae5923..d94393f 100644 --- a/progenitor-impl/tests/output/src/param_overrides_positional.rs +++ b/progenitor-impl/tests/output/src/param_overrides_positional.rs @@ -8,6 +8,35 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } } #[derive(Clone, Debug)] diff --git a/progenitor-impl/tests/output/src/propolis_server_builder.rs b/progenitor-impl/tests/output/src/propolis_server_builder.rs index 22ebc07..3a2ab18 100644 --- a/progenitor-impl/tests/output/src/propolis_server_builder.rs +++ b/progenitor-impl/tests/output/src/propolis_server_builder.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///CrucibleOpts /// ///
JSON schema @@ -832,8 +862,8 @@ pub mod types { } impl std::str::FromStr for InstanceState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "Creating" => Ok(Self::Creating), "Starting" => Ok(Self::Starting), @@ -845,28 +875,28 @@ pub mod types { "Repairing" => Ok(Self::Repairing), "Failed" => Ok(Self::Failed), "Destroyed" => Ok(Self::Destroyed), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for InstanceState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for InstanceState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for InstanceState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -1004,35 +1034,35 @@ pub mod types { } impl std::str::FromStr for InstanceStateRequested { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "Run" => Ok(Self::Run), "Stop" => Ok(Self::Stop), "Reboot" => Ok(Self::Reboot), "MigrateStart" => Ok(Self::MigrateStart), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for InstanceStateRequested { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for InstanceStateRequested { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for InstanceStateRequested { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -1109,8 +1139,8 @@ pub mod types { } impl std::str::FromStr for MigrationState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "Sync" => Ok(Self::Sync), "RamPush" => Ok(Self::RamPush), @@ -1122,28 +1152,28 @@ pub mod types { "RamPull" => Ok(Self::RamPull), "Finish" => Ok(Self::Finish), "Error" => Ok(Self::Error), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for MigrationState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for MigrationState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for MigrationState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -1528,6 +1558,7 @@ pub mod types { } } + /// Types for composing complex structures. pub mod builder { #[derive(Clone, Debug)] pub struct CrucibleOpts { @@ -1664,8 +1695,8 @@ pub mod types { } impl std::convert::TryFrom for super::CrucibleOpts { - type Error = String; - fn try_from(value: CrucibleOpts) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: CrucibleOpts) -> Result { Ok(Self { cert_pem: value.cert_pem?, control: value.control?, @@ -1749,8 +1780,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskAttachment { - type Error = String; - fn try_from(value: DiskAttachment) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskAttachment) -> Result { Ok(Self { disk_id: value.disk_id?, generation_id: value.generation_id?, @@ -1861,8 +1892,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskRequest { - type Error = String; - fn try_from(value: DiskRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskRequest) -> Result { Ok(Self { device: value.device?, gen: value.gen?, @@ -1938,8 +1969,8 @@ pub mod types { } impl std::convert::TryFrom for super::Error { - type Error = String; - fn try_from(value: Error) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Error) -> Result { Ok(Self { error_code: value.error_code?, message: value.message?, @@ -2021,8 +2052,8 @@ pub mod types { } impl std::convert::TryFrom for super::Instance { - type Error = String; - fn try_from(value: Instance) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Instance) -> Result { Ok(Self { disks: value.disks?, nics: value.nics?, @@ -2121,8 +2152,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceEnsureRequest { - type Error = String; - fn try_from(value: InstanceEnsureRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceEnsureRequest, + ) -> Result { Ok(Self { cloud_init_bytes: value.cloud_init_bytes?, disks: value.disks?, @@ -2172,8 +2205,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceEnsureResponse { - type Error = String; - fn try_from(value: InstanceEnsureResponse) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceEnsureResponse, + ) -> Result { Ok(Self { migrate: value.migrate?, }) @@ -2215,8 +2250,8 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceGetResponse { - type Error = String; - fn try_from(value: InstanceGetResponse) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: InstanceGetResponse) -> Result { Ok(Self { instance: value.instance?, }) @@ -2284,8 +2319,10 @@ pub mod types { impl std::convert::TryFrom for super::InstanceMigrateInitiateRequest { - type Error = String; - fn try_from(value: InstanceMigrateInitiateRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateInitiateRequest, + ) -> Result { Ok(Self { migration_id: value.migration_id?, src_addr: value.src_addr?, @@ -2333,8 +2370,10 @@ pub mod types { impl std::convert::TryFrom for super::InstanceMigrateInitiateResponse { - type Error = String; - fn try_from(value: InstanceMigrateInitiateResponse) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateInitiateResponse, + ) -> Result { Ok(Self { migration_id: value.migration_id?, }) @@ -2376,8 +2415,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceMigrateStatusRequest { - type Error = String; - fn try_from(value: InstanceMigrateStatusRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateStatusRequest, + ) -> Result { Ok(Self { migration_id: value.migration_id?, }) @@ -2419,8 +2460,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceMigrateStatusResponse { - type Error = String; - fn try_from(value: InstanceMigrateStatusResponse) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateStatusResponse, + ) -> Result { Ok(Self { state: value.state?, }) @@ -2534,8 +2577,8 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceProperties { - type Error = String; - fn try_from(value: InstanceProperties) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: InstanceProperties) -> Result { Ok(Self { bootrom_id: value.bootrom_id?, description: value.description?, @@ -2589,8 +2632,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceStateMonitorRequest { - type Error = String; - fn try_from(value: InstanceStateMonitorRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceStateMonitorRequest, + ) -> Result { Ok(Self { gen: value.gen? }) } } @@ -2640,8 +2685,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceStateMonitorResponse { - type Error = String; - fn try_from(value: InstanceStateMonitorResponse) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceStateMonitorResponse, + ) -> Result { Ok(Self { gen: value.gen?, state: value.state?, @@ -2697,8 +2744,8 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterface { - type Error = String; - fn try_from(value: NetworkInterface) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: NetworkInterface) -> Result { Ok(Self { attachment: value.attachment?, name: value.name?, @@ -2754,8 +2801,10 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterfaceRequest { - type Error = String; - fn try_from(value: NetworkInterfaceRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceRequest, + ) -> Result { Ok(Self { name: value.name?, slot: value.slot?, diff --git a/progenitor-impl/tests/output/src/propolis_server_builder_tagged.rs b/progenitor-impl/tests/output/src/propolis_server_builder_tagged.rs index 38c7dbd..48a5d46 100644 --- a/progenitor-impl/tests/output/src/propolis_server_builder_tagged.rs +++ b/progenitor-impl/tests/output/src/propolis_server_builder_tagged.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///CrucibleOpts /// ///
JSON schema @@ -820,8 +850,8 @@ pub mod types { } impl std::str::FromStr for InstanceState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "Creating" => Ok(Self::Creating), "Starting" => Ok(Self::Starting), @@ -833,28 +863,28 @@ pub mod types { "Repairing" => Ok(Self::Repairing), "Failed" => Ok(Self::Failed), "Destroyed" => Ok(Self::Destroyed), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for InstanceState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for InstanceState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for InstanceState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -980,35 +1010,35 @@ pub mod types { } impl std::str::FromStr for InstanceStateRequested { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "Run" => Ok(Self::Run), "Stop" => Ok(Self::Stop), "Reboot" => Ok(Self::Reboot), "MigrateStart" => Ok(Self::MigrateStart), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for InstanceStateRequested { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for InstanceStateRequested { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for InstanceStateRequested { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -1073,8 +1103,8 @@ pub mod types { } impl std::str::FromStr for MigrationState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "Sync" => Ok(Self::Sync), "RamPush" => Ok(Self::RamPush), @@ -1086,28 +1116,28 @@ pub mod types { "RamPull" => Ok(Self::RamPull), "Finish" => Ok(Self::Finish), "Error" => Ok(Self::Error), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for MigrationState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for MigrationState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for MigrationState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -1492,6 +1522,7 @@ pub mod types { } } + /// Types for composing complex structures. pub mod builder { #[derive(Clone, Debug)] pub struct CrucibleOpts { @@ -1628,8 +1659,8 @@ pub mod types { } impl std::convert::TryFrom for super::CrucibleOpts { - type Error = String; - fn try_from(value: CrucibleOpts) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: CrucibleOpts) -> Result { Ok(Self { cert_pem: value.cert_pem?, control: value.control?, @@ -1713,8 +1744,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskAttachment { - type Error = String; - fn try_from(value: DiskAttachment) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskAttachment) -> Result { Ok(Self { disk_id: value.disk_id?, generation_id: value.generation_id?, @@ -1825,8 +1856,8 @@ pub mod types { } impl std::convert::TryFrom for super::DiskRequest { - type Error = String; - fn try_from(value: DiskRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: DiskRequest) -> Result { Ok(Self { device: value.device?, gen: value.gen?, @@ -1902,8 +1933,8 @@ pub mod types { } impl std::convert::TryFrom for super::Error { - type Error = String; - fn try_from(value: Error) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Error) -> Result { Ok(Self { error_code: value.error_code?, message: value.message?, @@ -1985,8 +2016,8 @@ pub mod types { } impl std::convert::TryFrom for super::Instance { - type Error = String; - fn try_from(value: Instance) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Instance) -> Result { Ok(Self { disks: value.disks?, nics: value.nics?, @@ -2085,8 +2116,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceEnsureRequest { - type Error = String; - fn try_from(value: InstanceEnsureRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceEnsureRequest, + ) -> Result { Ok(Self { cloud_init_bytes: value.cloud_init_bytes?, disks: value.disks?, @@ -2136,8 +2169,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceEnsureResponse { - type Error = String; - fn try_from(value: InstanceEnsureResponse) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceEnsureResponse, + ) -> Result { Ok(Self { migrate: value.migrate?, }) @@ -2179,8 +2214,8 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceGetResponse { - type Error = String; - fn try_from(value: InstanceGetResponse) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: InstanceGetResponse) -> Result { Ok(Self { instance: value.instance?, }) @@ -2248,8 +2283,10 @@ pub mod types { impl std::convert::TryFrom for super::InstanceMigrateInitiateRequest { - type Error = String; - fn try_from(value: InstanceMigrateInitiateRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateInitiateRequest, + ) -> Result { Ok(Self { migration_id: value.migration_id?, src_addr: value.src_addr?, @@ -2297,8 +2334,10 @@ pub mod types { impl std::convert::TryFrom for super::InstanceMigrateInitiateResponse { - type Error = String; - fn try_from(value: InstanceMigrateInitiateResponse) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateInitiateResponse, + ) -> Result { Ok(Self { migration_id: value.migration_id?, }) @@ -2340,8 +2379,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceMigrateStatusRequest { - type Error = String; - fn try_from(value: InstanceMigrateStatusRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateStatusRequest, + ) -> Result { Ok(Self { migration_id: value.migration_id?, }) @@ -2383,8 +2424,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceMigrateStatusResponse { - type Error = String; - fn try_from(value: InstanceMigrateStatusResponse) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceMigrateStatusResponse, + ) -> Result { Ok(Self { state: value.state?, }) @@ -2498,8 +2541,8 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceProperties { - type Error = String; - fn try_from(value: InstanceProperties) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: InstanceProperties) -> Result { Ok(Self { bootrom_id: value.bootrom_id?, description: value.description?, @@ -2553,8 +2596,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceStateMonitorRequest { - type Error = String; - fn try_from(value: InstanceStateMonitorRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceStateMonitorRequest, + ) -> Result { Ok(Self { gen: value.gen? }) } } @@ -2604,8 +2649,10 @@ pub mod types { } impl std::convert::TryFrom for super::InstanceStateMonitorResponse { - type Error = String; - fn try_from(value: InstanceStateMonitorResponse) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: InstanceStateMonitorResponse, + ) -> Result { Ok(Self { gen: value.gen?, state: value.state?, @@ -2661,8 +2708,8 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterface { - type Error = String; - fn try_from(value: NetworkInterface) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: NetworkInterface) -> Result { Ok(Self { attachment: value.attachment?, name: value.name?, @@ -2718,8 +2765,10 @@ pub mod types { } impl std::convert::TryFrom for super::NetworkInterfaceRequest { - type Error = String; - fn try_from(value: NetworkInterfaceRequest) -> Result { + type Error = super::error::ConversionError; + fn try_from( + value: NetworkInterfaceRequest, + ) -> Result { Ok(Self { name: value.name?, slot: value.slot?, diff --git a/progenitor-impl/tests/output/src/propolis_server_positional.rs b/progenitor-impl/tests/output/src/propolis_server_positional.rs index e520be9..47562e6 100644 --- a/progenitor-impl/tests/output/src/propolis_server_positional.rs +++ b/progenitor-impl/tests/output/src/propolis_server_positional.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///CrucibleOpts /// ///
JSON schema @@ -742,8 +772,8 @@ pub mod types { } impl std::str::FromStr for InstanceState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "Creating" => Ok(Self::Creating), "Starting" => Ok(Self::Starting), @@ -755,28 +785,28 @@ pub mod types { "Repairing" => Ok(Self::Repairing), "Failed" => Ok(Self::Failed), "Destroyed" => Ok(Self::Destroyed), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for InstanceState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for InstanceState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for InstanceState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -890,35 +920,35 @@ pub mod types { } impl std::str::FromStr for InstanceStateRequested { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "Run" => Ok(Self::Run), "Stop" => Ok(Self::Stop), "Reboot" => Ok(Self::Reboot), "MigrateStart" => Ok(Self::MigrateStart), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for InstanceStateRequested { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for InstanceStateRequested { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for InstanceStateRequested { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } @@ -983,8 +1013,8 @@ pub mod types { } impl std::str::FromStr for MigrationState { - type Err = &'static str; - fn from_str(value: &str) -> Result { + type Err = self::error::ConversionError; + fn from_str(value: &str) -> Result { match value { "Sync" => Ok(Self::Sync), "RamPush" => Ok(Self::RamPush), @@ -996,28 +1026,28 @@ pub mod types { "RamPull" => Ok(Self::RamPull), "Finish" => Ok(Self::Finish), "Error" => Ok(Self::Error), - _ => Err("invalid value"), + _ => Err("invalid value".into()), } } } impl std::convert::TryFrom<&str> for MigrationState { - type Error = &'static str; - fn try_from(value: &str) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &str) -> Result { value.parse() } } impl std::convert::TryFrom<&String> for MigrationState { - type Error = &'static str; - fn try_from(value: &String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: &String) -> Result { value.parse() } } impl std::convert::TryFrom for MigrationState { - type Error = &'static str; - fn try_from(value: String) -> Result { + type Error = self::error::ConversionError; + fn try_from(value: String) -> Result { value.parse() } } diff --git a/progenitor-impl/tests/output/src/test_default_params_builder.rs b/progenitor-impl/tests/output/src/test_default_params_builder.rs index e6f5410..fb5b93b 100644 --- a/progenitor-impl/tests/output/src/test_default_params_builder.rs +++ b/progenitor-impl/tests/output/src/test_default_params_builder.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///BodyWithDefaults /// ///
JSON schema @@ -112,6 +142,7 @@ pub mod types { } } + /// Types for composing complex structures. pub mod builder { #[derive(Clone, Debug)] pub struct BodyWithDefaults { @@ -176,8 +207,8 @@ pub mod types { } impl std::convert::TryFrom for super::BodyWithDefaults { - type Error = String; - fn try_from(value: BodyWithDefaults) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: BodyWithDefaults) -> Result { Ok(Self { forty_two: value.forty_two?, s: value.s?, @@ -249,8 +280,8 @@ pub mod types { } impl std::convert::TryFrom for super::Error { - type Error = String; - fn try_from(value: Error) -> Result { + type Error = super::error::ConversionError; + fn try_from(value: Error) -> Result { Ok(Self { error_code: value.error_code?, message: value.message?, @@ -270,6 +301,7 @@ pub mod types { } } + /// Generation of default values for serde. pub mod defaults { pub(super) fn default_u64() -> T where diff --git a/progenitor-impl/tests/output/src/test_default_params_positional.rs b/progenitor-impl/tests/output/src/test_default_params_positional.rs index 298ed1c..d3f9f33 100644 --- a/progenitor-impl/tests/output/src/test_default_params_positional.rs +++ b/progenitor-impl/tests/output/src/test_default_params_positional.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///BodyWithDefaults /// ///
JSON schema @@ -100,6 +130,7 @@ pub mod types { } } + /// Generation of default values for serde. pub mod defaults { pub(super) fn default_u64() -> T where diff --git a/progenitor-impl/tests/output/src/test_freeform_response.rs b/progenitor-impl/tests/output/src/test_freeform_response.rs index c439a4b..e694729 100644 --- a/progenitor-impl/tests/output/src/test_freeform_response.rs +++ b/progenitor-impl/tests/output/src/test_freeform_response.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///Error information from a response. /// ///
JSON schema diff --git a/progenitor-impl/tests/output/src/test_renamed_parameters.rs b/progenitor-impl/tests/output/src/test_renamed_parameters.rs index 541e7fb..f8e9258 100644 --- a/progenitor-impl/tests/output/src/test_renamed_parameters.rs +++ b/progenitor-impl/tests/output/src/test_renamed_parameters.rs @@ -8,6 +8,36 @@ pub mod types { use serde::{Deserialize, Serialize}; #[allow(unused_imports)] use std::convert::TryFrom; + /// Error types. + pub mod error { + /// 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()) + } + } + } + ///Error information from a response. /// ///
JSON schema