diff --git a/Cargo.lock b/Cargo.lock index ffb5a86..9509fdb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2025,7 +2025,7 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "typify" version = "0.0.11-dev" -source = "git+https://github.com/oxidecomputer/typify#2790d798ea650c08686d014fdd87c25d942806b1" +source = "git+https://github.com/oxidecomputer/typify#c18d0452db86d57318eec40a14c5aca5a079e6f8" dependencies = [ "typify-impl", "typify-macro", @@ -2034,7 +2034,7 @@ dependencies = [ [[package]] name = "typify-impl" version = "0.0.11-dev" -source = "git+https://github.com/oxidecomputer/typify#2790d798ea650c08686d014fdd87c25d942806b1" +source = "git+https://github.com/oxidecomputer/typify#c18d0452db86d57318eec40a14c5aca5a079e6f8" dependencies = [ "heck", "log", @@ -2052,7 +2052,7 @@ dependencies = [ [[package]] name = "typify-macro" version = "0.0.11-dev" -source = "git+https://github.com/oxidecomputer/typify#2790d798ea650c08686d014fdd87c25d942806b1" +source = "git+https://github.com/oxidecomputer/typify#c18d0452db86d57318eec40a14c5aca5a079e6f8" dependencies = [ "proc-macro2", "quote", diff --git a/progenitor-impl/tests/output/buildomat-builder-tagged.out b/progenitor-impl/tests/output/buildomat-builder-tagged.out index 8ca0695..e40111d 100644 --- a/progenitor-impl/tests/output/buildomat-builder-tagged.out +++ b/progenitor-impl/tests/output/buildomat-builder-tagged.out @@ -325,7 +325,7 @@ pub mod types { impl std::convert::TryFrom for super::Task { type Error = String; - fn try_from(value: Task) -> Result { + fn try_from(value: Task) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -399,7 +399,7 @@ pub mod types { impl std::convert::TryFrom for super::TaskEvent { type Error = String; - fn try_from(value: TaskEvent) -> Result { + fn try_from(value: TaskEvent) -> Result { Ok(Self { payload: value.payload?, seq: value.seq?, @@ -460,7 +460,7 @@ pub mod types { impl std::convert::TryFrom for super::TaskOutput { type Error = String; - fn try_from(value: TaskOutput) -> Result { + fn try_from(value: TaskOutput) -> Result { Ok(Self { id: value.id?, path: value.path?, @@ -520,7 +520,7 @@ pub mod types { impl std::convert::TryFrom for super::TaskSubmit { type Error = String; - fn try_from(value: TaskSubmit) -> Result { + fn try_from(value: TaskSubmit) -> Result { Ok(Self { name: value.name?, output_rules: value.output_rules?, @@ -556,7 +556,7 @@ pub mod types { impl std::convert::TryFrom for super::TaskSubmitResult { type Error = String; - fn try_from(value: TaskSubmitResult) -> Result { + fn try_from(value: TaskSubmitResult) -> Result { Ok(Self { id: value.id? }) } } @@ -588,7 +588,7 @@ pub mod types { impl std::convert::TryFrom for super::UploadedChunk { type Error = String; - fn try_from(value: UploadedChunk) -> Result { + fn try_from(value: UploadedChunk) -> Result { Ok(Self { id: value.id? }) } } @@ -620,7 +620,7 @@ pub mod types { impl std::convert::TryFrom for super::UserCreate { type Error = String; - fn try_from(value: UserCreate) -> Result { + fn try_from(value: UserCreate) -> Result { Ok(Self { name: value.name? }) } } @@ -676,7 +676,7 @@ pub mod types { impl std::convert::TryFrom for super::UserCreateResult { type Error = String; - fn try_from(value: UserCreateResult) -> Result { + fn try_from(value: UserCreateResult) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -724,7 +724,7 @@ pub mod types { impl std::convert::TryFrom for super::WhoamiResult { type Error = String; - fn try_from(value: WhoamiResult) -> Result { + fn try_from(value: WhoamiResult) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -819,7 +819,7 @@ pub mod types { impl std::convert::TryFrom for super::Worker { type Error = String; - fn try_from(value: Worker) -> Result { + fn try_from(value: Worker) -> Result { Ok(Self { deleted: value.deleted?, id: value.id?, @@ -882,7 +882,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerAddOutput { type Error = String; - fn try_from(value: WorkerAddOutput) -> Result { + fn try_from(value: WorkerAddOutput) -> Result { Ok(Self { chunks: value.chunks?, path: value.path?, @@ -942,7 +942,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerAppendTask { type Error = String; - fn try_from(value: WorkerAppendTask) -> Result { + fn try_from(value: WorkerAppendTask) -> Result { Ok(Self { payload: value.payload?, stream: value.stream?, @@ -990,7 +990,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerBootstrap { type Error = String; - fn try_from(value: WorkerBootstrap) -> Result { + fn try_from(value: WorkerBootstrap) -> Result { Ok(Self { bootstrap: value.bootstrap?, token: value.token?, @@ -1025,7 +1025,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerBootstrapResult { type Error = String; - fn try_from(value: WorkerBootstrapResult) -> Result { + fn try_from(value: WorkerBootstrapResult) -> Result { Ok(Self { id: value.id? }) } } @@ -1057,7 +1057,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerCompleteTask { type Error = String; - fn try_from(value: WorkerCompleteTask) -> Result { + fn try_from(value: WorkerCompleteTask) -> Result { Ok(Self { failed: value.failed?, }) @@ -1103,7 +1103,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerPingResult { type Error = String; - fn try_from(value: WorkerPingResult) -> Result { + fn try_from(value: WorkerPingResult) -> Result { Ok(Self { poweroff: value.poweroff?, task: value.task?, @@ -1162,7 +1162,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerPingTask { type Error = String; - fn try_from(value: WorkerPingTask) -> Result { + fn try_from(value: WorkerPingTask) -> Result { Ok(Self { id: value.id?, output_rules: value.output_rules?, @@ -1222,7 +1222,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerTask { type Error = String; - fn try_from(value: WorkerTask) -> Result { + fn try_from(value: WorkerTask) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -1258,7 +1258,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkersResult { type Error = String; - fn try_from(value: WorkersResult) -> Result { + fn try_from(value: WorkersResult) -> Result { Ok(Self { workers: value.workers?, }) diff --git a/progenitor-impl/tests/output/buildomat-builder.out b/progenitor-impl/tests/output/buildomat-builder.out index 9dcc7a4..f78c17f 100644 --- a/progenitor-impl/tests/output/buildomat-builder.out +++ b/progenitor-impl/tests/output/buildomat-builder.out @@ -325,7 +325,7 @@ pub mod types { impl std::convert::TryFrom for super::Task { type Error = String; - fn try_from(value: Task) -> Result { + fn try_from(value: Task) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -399,7 +399,7 @@ pub mod types { impl std::convert::TryFrom for super::TaskEvent { type Error = String; - fn try_from(value: TaskEvent) -> Result { + fn try_from(value: TaskEvent) -> Result { Ok(Self { payload: value.payload?, seq: value.seq?, @@ -460,7 +460,7 @@ pub mod types { impl std::convert::TryFrom for super::TaskOutput { type Error = String; - fn try_from(value: TaskOutput) -> Result { + fn try_from(value: TaskOutput) -> Result { Ok(Self { id: value.id?, path: value.path?, @@ -520,7 +520,7 @@ pub mod types { impl std::convert::TryFrom for super::TaskSubmit { type Error = String; - fn try_from(value: TaskSubmit) -> Result { + fn try_from(value: TaskSubmit) -> Result { Ok(Self { name: value.name?, output_rules: value.output_rules?, @@ -556,7 +556,7 @@ pub mod types { impl std::convert::TryFrom for super::TaskSubmitResult { type Error = String; - fn try_from(value: TaskSubmitResult) -> Result { + fn try_from(value: TaskSubmitResult) -> Result { Ok(Self { id: value.id? }) } } @@ -588,7 +588,7 @@ pub mod types { impl std::convert::TryFrom for super::UploadedChunk { type Error = String; - fn try_from(value: UploadedChunk) -> Result { + fn try_from(value: UploadedChunk) -> Result { Ok(Self { id: value.id? }) } } @@ -620,7 +620,7 @@ pub mod types { impl std::convert::TryFrom for super::UserCreate { type Error = String; - fn try_from(value: UserCreate) -> Result { + fn try_from(value: UserCreate) -> Result { Ok(Self { name: value.name? }) } } @@ -676,7 +676,7 @@ pub mod types { impl std::convert::TryFrom for super::UserCreateResult { type Error = String; - fn try_from(value: UserCreateResult) -> Result { + fn try_from(value: UserCreateResult) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -724,7 +724,7 @@ pub mod types { impl std::convert::TryFrom for super::WhoamiResult { type Error = String; - fn try_from(value: WhoamiResult) -> Result { + fn try_from(value: WhoamiResult) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -819,7 +819,7 @@ pub mod types { impl std::convert::TryFrom for super::Worker { type Error = String; - fn try_from(value: Worker) -> Result { + fn try_from(value: Worker) -> Result { Ok(Self { deleted: value.deleted?, id: value.id?, @@ -882,7 +882,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerAddOutput { type Error = String; - fn try_from(value: WorkerAddOutput) -> Result { + fn try_from(value: WorkerAddOutput) -> Result { Ok(Self { chunks: value.chunks?, path: value.path?, @@ -942,7 +942,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerAppendTask { type Error = String; - fn try_from(value: WorkerAppendTask) -> Result { + fn try_from(value: WorkerAppendTask) -> Result { Ok(Self { payload: value.payload?, stream: value.stream?, @@ -990,7 +990,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerBootstrap { type Error = String; - fn try_from(value: WorkerBootstrap) -> Result { + fn try_from(value: WorkerBootstrap) -> Result { Ok(Self { bootstrap: value.bootstrap?, token: value.token?, @@ -1025,7 +1025,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerBootstrapResult { type Error = String; - fn try_from(value: WorkerBootstrapResult) -> Result { + fn try_from(value: WorkerBootstrapResult) -> Result { Ok(Self { id: value.id? }) } } @@ -1057,7 +1057,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerCompleteTask { type Error = String; - fn try_from(value: WorkerCompleteTask) -> Result { + fn try_from(value: WorkerCompleteTask) -> Result { Ok(Self { failed: value.failed?, }) @@ -1103,7 +1103,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerPingResult { type Error = String; - fn try_from(value: WorkerPingResult) -> Result { + fn try_from(value: WorkerPingResult) -> Result { Ok(Self { poweroff: value.poweroff?, task: value.task?, @@ -1162,7 +1162,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerPingTask { type Error = String; - fn try_from(value: WorkerPingTask) -> Result { + fn try_from(value: WorkerPingTask) -> Result { Ok(Self { id: value.id?, output_rules: value.output_rules?, @@ -1222,7 +1222,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkerTask { type Error = String; - fn try_from(value: WorkerTask) -> Result { + fn try_from(value: WorkerTask) -> Result { Ok(Self { id: value.id?, name: value.name?, @@ -1258,7 +1258,7 @@ pub mod types { impl std::convert::TryFrom for super::WorkersResult { type Error = String; - fn try_from(value: WorkersResult) -> Result { + fn try_from(value: WorkersResult) -> Result { Ok(Self { workers: value.workers?, }) diff --git a/progenitor-impl/tests/output/keeper-builder-tagged.out b/progenitor-impl/tests/output/keeper-builder-tagged.out index c680184..e5d8ce1 100644 --- a/progenitor-impl/tests/output/keeper-builder-tagged.out +++ b/progenitor-impl/tests/output/keeper-builder-tagged.out @@ -176,7 +176,7 @@ pub mod types { impl std::convert::TryFrom for super::EnrolBody { type Error = String; - fn try_from(value: EnrolBody) -> Result { + fn try_from(value: EnrolBody) -> Result { Ok(Self { host: value.host?, key: value.key?, @@ -211,7 +211,7 @@ pub mod types { impl std::convert::TryFrom for super::GlobalJobsResult { type Error = String; - fn try_from(value: GlobalJobsResult) -> Result { + fn try_from(value: GlobalJobsResult) -> Result { Ok(Self { summary: value.summary?, }) @@ -269,7 +269,7 @@ pub mod types { impl std::convert::TryFrom for super::OutputRecord { type Error = String; - fn try_from(value: OutputRecord) -> Result { + fn try_from(value: OutputRecord) -> Result { Ok(Self { msg: value.msg?, stream: value.stream?, @@ -317,7 +317,7 @@ pub mod types { impl std::convert::TryFrom for super::PingResult { type Error = String; - fn try_from(value: PingResult) -> Result { + fn try_from(value: PingResult) -> Result { Ok(Self { host: value.host?, ok: value.ok?, @@ -388,7 +388,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportFinishBody { type Error = String; - fn try_from(value: ReportFinishBody) -> Result { + fn try_from(value: ReportFinishBody) -> Result { Ok(Self { duration_millis: value.duration_millis?, end_time: value.end_time?, @@ -473,7 +473,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportId { type Error = String; - fn try_from(value: ReportId) -> Result { + fn try_from(value: ReportId) -> Result { Ok(Self { host: value.host?, job: value.job?, @@ -523,7 +523,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportOutputBody { type Error = String; - fn try_from(value: ReportOutputBody) -> Result { + fn try_from(value: ReportOutputBody) -> Result { Ok(Self { id: value.id?, record: value.record?, @@ -558,7 +558,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportResult { type Error = String; - fn try_from(value: ReportResult) -> Result { + fn try_from(value: ReportResult) -> Result { Ok(Self { existed_already: value.existed_already?, }) @@ -616,7 +616,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportStartBody { type Error = String; - fn try_from(value: ReportStartBody) -> Result { + fn try_from(value: ReportStartBody) -> Result { Ok(Self { id: value.id?, script: value.script?, @@ -715,7 +715,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportSummary { type Error = String; - fn try_from(value: ReportSummary) -> Result { + 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/keeper-builder.out b/progenitor-impl/tests/output/keeper-builder.out index a8e6517..148e157 100644 --- a/progenitor-impl/tests/output/keeper-builder.out +++ b/progenitor-impl/tests/output/keeper-builder.out @@ -176,7 +176,7 @@ pub mod types { impl std::convert::TryFrom for super::EnrolBody { type Error = String; - fn try_from(value: EnrolBody) -> Result { + fn try_from(value: EnrolBody) -> Result { Ok(Self { host: value.host?, key: value.key?, @@ -211,7 +211,7 @@ pub mod types { impl std::convert::TryFrom for super::GlobalJobsResult { type Error = String; - fn try_from(value: GlobalJobsResult) -> Result { + fn try_from(value: GlobalJobsResult) -> Result { Ok(Self { summary: value.summary?, }) @@ -269,7 +269,7 @@ pub mod types { impl std::convert::TryFrom for super::OutputRecord { type Error = String; - fn try_from(value: OutputRecord) -> Result { + fn try_from(value: OutputRecord) -> Result { Ok(Self { msg: value.msg?, stream: value.stream?, @@ -317,7 +317,7 @@ pub mod types { impl std::convert::TryFrom for super::PingResult { type Error = String; - fn try_from(value: PingResult) -> Result { + fn try_from(value: PingResult) -> Result { Ok(Self { host: value.host?, ok: value.ok?, @@ -388,7 +388,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportFinishBody { type Error = String; - fn try_from(value: ReportFinishBody) -> Result { + fn try_from(value: ReportFinishBody) -> Result { Ok(Self { duration_millis: value.duration_millis?, end_time: value.end_time?, @@ -473,7 +473,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportId { type Error = String; - fn try_from(value: ReportId) -> Result { + fn try_from(value: ReportId) -> Result { Ok(Self { host: value.host?, job: value.job?, @@ -523,7 +523,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportOutputBody { type Error = String; - fn try_from(value: ReportOutputBody) -> Result { + fn try_from(value: ReportOutputBody) -> Result { Ok(Self { id: value.id?, record: value.record?, @@ -558,7 +558,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportResult { type Error = String; - fn try_from(value: ReportResult) -> Result { + fn try_from(value: ReportResult) -> Result { Ok(Self { existed_already: value.existed_already?, }) @@ -616,7 +616,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportStartBody { type Error = String; - fn try_from(value: ReportStartBody) -> Result { + fn try_from(value: ReportStartBody) -> Result { Ok(Self { id: value.id?, script: value.script?, @@ -715,7 +715,7 @@ pub mod types { impl std::convert::TryFrom for super::ReportSummary { type Error = String; - fn try_from(value: ReportSummary) -> Result { + 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/nexus-builder-tagged.out b/progenitor-impl/tests/output/nexus-builder-tagged.out index c52dbce..e40f252 100644 --- a/progenitor-impl/tests/output/nexus-builder-tagged.out +++ b/progenitor-impl/tests/output/nexus-builder-tagged.out @@ -81,14 +81,14 @@ pub mod types { pub struct BlockSize(i64); impl std::ops::Deref for BlockSize { type Target = i64; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &i64 { &self.0 } } impl std::convert::TryFrom for BlockSize { type Error = &'static str; - fn try_from(value: i64) -> Result { + fn try_from(value: i64) -> Result { if ![512_i64, 2048_i64, 4096_i64].contains(&value) { Err("invalid value") } else { @@ -108,7 +108,7 @@ pub mod types { pub struct ByteCount(pub u64); impl std::ops::Deref for ByteCount { type Target = u64; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &u64 { &self.0 } } @@ -204,7 +204,7 @@ pub mod types { impl std::str::FromStr for DatumType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "bool" => Ok(Self::Bool), "i64" => Ok(Self::I64), @@ -220,6 +220,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for DatumType { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct DerEncodedKeyPair { ///request signing private key (base64 encoded der file) @@ -368,7 +382,7 @@ pub mod types { impl std::str::FromStr for DiskMetricName { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "activated" => Ok(Self::Activated), "flush" => Ok(Self::Flush), @@ -381,6 +395,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for DiskMetricName { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct DiskResultsPage { @@ -548,7 +576,7 @@ pub mod types { impl std::str::FromStr for FieldSource { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "target" => Ok(Self::Target), "metric" => Ok(Self::Metric), @@ -557,6 +585,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for FieldSource { + type Error = &'static str; + 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 { + value.parse() + } + } + ///The `FieldType` identifies the data type of a target or metric field. #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum FieldType { @@ -586,7 +628,7 @@ pub mod types { impl std::str::FromStr for FieldType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "string" => Ok(Self::String), "i64" => Ok(Self::I64), @@ -598,6 +640,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for FieldType { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum FleetRole { #[serde(rename = "admin")] @@ -620,7 +676,7 @@ pub mod types { impl std::str::FromStr for FleetRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -630,6 +686,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for FleetRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -867,7 +937,7 @@ pub mod types { impl std::str::FromStr for IdSortMode { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "id_ascending" => Ok(Self::IdAscending), _ => Err("invalid value"), @@ -875,6 +945,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IdSortMode { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of an [`IdentityProvider`] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct IdentityProvider { @@ -930,7 +1014,7 @@ pub mod types { impl std::str::FromStr for IdentityProviderType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "saml" => Ok(Self::Saml), _ => Err("invalid value"), @@ -938,6 +1022,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IdentityProviderType { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Describes what kind of identity is described by an id #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum IdentityType { @@ -955,7 +1053,7 @@ pub mod types { impl std::str::FromStr for IdentityType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "silo_user" => Ok(Self::SiloUser), _ => Err("invalid value"), @@ -963,6 +1061,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IdentityType { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "type")] pub enum IdpMetadataSource { @@ -1090,7 +1202,7 @@ pub mod types { pub struct InstanceCpuCount(pub u16); impl std::ops::Deref for InstanceCpuCount { type Target = u16; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &u16 { &self.0 } } @@ -1264,7 +1376,7 @@ pub mod types { impl std::str::FromStr for InstanceState { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "creating" => Ok(Self::Creating), "starting" => Ok(Self::Starting), @@ -1281,6 +1393,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for InstanceState { + type Error = &'static str; + 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 { + value.parse() + } + } + ///The kind of an external IP address for an instance #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum IpKind { @@ -1301,7 +1427,7 @@ pub mod types { impl std::str::FromStr for IpKind { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "ephemeral" => Ok(Self::Ephemeral), "floating" => Ok(Self::Floating), @@ -1310,6 +1436,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IpKind { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(untagged)] pub enum IpNet { @@ -1317,27 +1457,30 @@ pub mod types { V6(Ipv6Net), } + impl std::str::FromStr for IpNet { + type Err = &'static str; + 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") + } + } + } + impl std::convert::TryFrom<&str> for IpNet { type Error = &'static str; - fn try_from(value: &str) -> Result { - Err("") - .or_else(|_: Self::Error| Ok(Self::V4(Ipv4Net::try_from(value)?))) - .or_else(|_: Self::Error| Ok(Self::V6(Ipv6Net::try_from(value)?))) - .map_err(|_: Self::Error| "string conversion failed for all variants") + 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 { - Self::try_from(value.as_str()) - } - } - - impl std::convert::TryFrom for IpNet { - type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1465,30 +1608,30 @@ pub mod types { pub struct Ipv4Net(String); impl std::ops::Deref for Ipv4Net { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for Ipv4Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for Ipv4Net { + type Err = &'static str; + fn from_str(value: &str) -> Result { if regress :: Regex :: new ("^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([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])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([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])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$\"") ; } Ok(Self(value.to_string())) } } - impl std::convert::TryFrom<&String> for Ipv4Net { + impl std::convert::TryFrom<&str> for Ipv4Net { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for Ipv4Net { + impl std::convert::TryFrom<&String> for Ipv4Net { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1497,8 +1640,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1522,30 +1666,30 @@ pub mod types { pub struct Ipv6Net(String); impl std::ops::Deref for Ipv6Net { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for Ipv6Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for Ipv6Net { + type Err = &'static str; + 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])$") . unwrap () . find (value) . is_none () { 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])$\"") ; } Ok(Self(value.to_string())) } } - impl std::convert::TryFrom<&String> for Ipv6Net { + impl std::convert::TryFrom<&str> for Ipv6Net { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for Ipv6Net { + impl std::convert::TryFrom<&String> for Ipv6Net { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1554,8 +1698,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1580,14 +1725,14 @@ pub mod types { pub struct L4PortRange(String); impl std::ops::Deref for L4PortRange { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for L4PortRange { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for L4PortRange { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 11usize { return Err("longer than 11 characters"); } @@ -1605,17 +1750,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for L4PortRange { + impl std::convert::TryFrom<&str> for L4PortRange { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for L4PortRange { + impl std::convert::TryFrom<&String> for L4PortRange { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1624,8 +1769,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1634,14 +1780,14 @@ pub mod types { pub struct MacAddr(String); impl std::ops::Deref for MacAddr { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for MacAddr { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for MacAddr { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 17usize { return Err("longer than 17 characters"); } @@ -1659,17 +1805,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for MacAddr { + impl std::convert::TryFrom<&str> for MacAddr { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for MacAddr { + impl std::convert::TryFrom<&String> for MacAddr { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1678,8 +1824,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1719,14 +1866,14 @@ pub mod types { pub struct Name(String); impl std::ops::Deref for Name { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for Name { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for Name { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 63usize { return Err("longer than 63 characters"); } @@ -1735,17 +1882,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for Name { + impl std::convert::TryFrom<&str> for Name { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for Name { + impl std::convert::TryFrom<&String> for Name { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1754,8 +1901,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1782,7 +1930,7 @@ pub mod types { impl std::str::FromStr for NameOrIdSortMode { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), "name_descending" => Ok(Self::NameDescending), @@ -1792,6 +1940,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for NameOrIdSortMode { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Supported set of sort modes for scanning by name only /// ///Currently, we only support scanning in ascending order. @@ -1811,7 +1973,7 @@ pub mod types { impl std::str::FromStr for NameSortMode { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), _ => Err("invalid value"), @@ -1819,6 +1981,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for NameSortMode { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A `NetworkInterface` represents a virtual network interface device. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct NetworkInterface { @@ -1996,7 +2172,7 @@ pub mod types { impl std::str::FromStr for OrganizationRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -2006,6 +2182,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for OrganizationRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -2133,7 +2323,7 @@ pub mod types { impl std::str::FromStr for ProjectRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -2143,6 +2333,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for ProjectRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -2247,14 +2451,14 @@ pub mod types { pub struct RoleName(String); impl std::ops::Deref for RoleName { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for RoleName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for RoleName { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 63usize { return Err("longer than 63 characters"); } @@ -2269,17 +2473,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for RoleName { + impl std::convert::TryFrom<&str> for RoleName { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for RoleName { + impl std::convert::TryFrom<&String> for RoleName { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -2288,8 +2492,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -2427,7 +2632,7 @@ pub mod types { impl std::str::FromStr for RouterRouteKind { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "default" => Ok(Self::Default), "vpc_subnet" => Ok(Self::VpcSubnet), @@ -2438,6 +2643,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for RouterRouteKind { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct RouterRouteResultsPage { @@ -2671,7 +2890,7 @@ pub mod types { impl std::str::FromStr for SiloRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -2681,6 +2900,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for SiloRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -2883,14 +3116,14 @@ pub mod types { pub struct TimeseriesName(String); impl std::ops::Deref for TimeseriesName { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for TimeseriesName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for TimeseriesName { + type Err = &'static str; + 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]+))*)", ) @@ -2904,17 +3137,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for TimeseriesName { + impl std::convert::TryFrom<&str> for TimeseriesName { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for TimeseriesName { + impl std::convert::TryFrom<&String> for TimeseriesName { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -2923,8 +3156,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -3033,7 +3267,7 @@ pub mod types { impl std::str::FromStr for UserProvisionType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "fixed" => Ok(Self::Fixed), "jit" => Ok(Self::Jit), @@ -3042,6 +3276,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for UserProvisionType { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for UserProvisionType { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct UserResultsPage { @@ -3163,7 +3411,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleAction { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "allow" => Ok(Self::Allow), "deny" => Ok(Self::Deny), @@ -3172,6 +3420,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleAction { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum VpcFirewallRuleDirection { #[serde(rename = "inbound")] @@ -3191,7 +3453,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleDirection { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "inbound" => Ok(Self::Inbound), "outbound" => Ok(Self::Outbound), @@ -3200,6 +3462,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleDirection { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Filter for a firewall rule. A given packet must match every field that /// is present for the rule to apply to it. A packet matches a field if any /// entry in that field matches the packet. @@ -3268,7 +3544,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleProtocol { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "TCP" => Ok(Self::Tcp), "UDP" => Ok(Self::Udp), @@ -3278,6 +3554,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleProtocol { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum VpcFirewallRuleStatus { #[serde(rename = "disabled")] @@ -3297,7 +3587,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleStatus { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "disabled" => Ok(Self::Disabled), "enabled" => Ok(Self::Enabled), @@ -3306,6 +3596,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleStatus { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to /// which a firewall rule applies. #[derive(Clone, Debug, Deserialize, Serialize)] @@ -3455,7 +3759,7 @@ pub mod types { impl std::str::FromStr for VpcRouterKind { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "system" => Ok(Self::System), "custom" => Ok(Self::Custom), @@ -3464,6 +3768,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcRouterKind { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct VpcRouterResultsPage { @@ -3641,7 +3959,7 @@ pub mod types { impl std::convert::TryFrom for super::Bindouble { type Error = String; - fn try_from(value: Bindouble) -> Result { + fn try_from(value: Bindouble) -> Result { Ok(Self { count: value.count?, range: value.range?, @@ -3688,7 +4006,7 @@ pub mod types { impl std::convert::TryFrom for super::Binint64 { type Error = String; - fn try_from(value: Binint64) -> Result { + fn try_from(value: Binint64) -> Result { Ok(Self { count: value.count?, range: value.range?, @@ -3735,7 +4053,7 @@ pub mod types { impl std::convert::TryFrom for super::Cumulativedouble { type Error = String; - fn try_from(value: Cumulativedouble) -> Result { + fn try_from(value: Cumulativedouble) -> Result { Ok(Self { start_time: value.start_time?, value: value.value?, @@ -3782,7 +4100,7 @@ pub mod types { impl std::convert::TryFrom for super::Cumulativeint64 { type Error = String; - fn try_from(value: Cumulativeint64) -> Result { + fn try_from(value: Cumulativeint64) -> Result { Ok(Self { start_time: value.start_time?, value: value.value?, @@ -3829,7 +4147,7 @@ pub mod types { impl std::convert::TryFrom for super::DerEncodedKeyPair { type Error = String; - fn try_from(value: DerEncodedKeyPair) -> Result { + fn try_from(value: DerEncodedKeyPair) -> Result { Ok(Self { private_key: value.private_key?, public_cert: value.public_cert?, @@ -3888,7 +4206,7 @@ pub mod types { impl std::convert::TryFrom for super::DeviceAccessTokenRequest { type Error = String; - fn try_from(value: DeviceAccessTokenRequest) -> Result { + fn try_from(value: DeviceAccessTokenRequest) -> Result { Ok(Self { client_id: value.client_id?, device_code: value.device_code?, @@ -3924,7 +4242,7 @@ pub mod types { impl std::convert::TryFrom for super::DeviceAuthRequest { type Error = String; - fn try_from(value: DeviceAuthRequest) -> Result { + fn try_from(value: DeviceAuthRequest) -> Result { Ok(Self { client_id: value.client_id?, }) @@ -3958,7 +4276,7 @@ pub mod types { impl std::convert::TryFrom for super::DeviceAuthVerify { type Error = String; - fn try_from(value: DeviceAuthVerify) -> Result { + fn try_from(value: DeviceAuthVerify) -> Result { Ok(Self { user_code: value.user_code?, }) @@ -4124,7 +4442,7 @@ pub mod types { impl std::convert::TryFrom for super::Disk { type Error = String; - fn try_from(value: Disk) -> Result { + fn try_from(value: Disk) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -4205,7 +4523,7 @@ pub mod types { impl std::convert::TryFrom for super::DiskCreate { type Error = String; - fn try_from(value: DiskCreate) -> Result { + fn try_from(value: DiskCreate) -> Result { Ok(Self { description: value.description?, disk_source: value.disk_source?, @@ -4242,7 +4560,7 @@ pub mod types { impl std::convert::TryFrom for super::DiskIdentifier { type Error = String; - fn try_from(value: DiskIdentifier) -> Result { + fn try_from(value: DiskIdentifier) -> Result { Ok(Self { name: value.name? }) } } @@ -4286,7 +4604,7 @@ pub mod types { impl std::convert::TryFrom for super::DiskResultsPage { type Error = String; - fn try_from(value: DiskResultsPage) -> Result { + fn try_from(value: DiskResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -4333,7 +4651,7 @@ pub mod types { impl std::convert::TryFrom for super::Distribution { type Error = String; - fn try_from(value: Distribution) -> Result { + fn try_from(value: Distribution) -> Result { Ok(Self { name: value.name?, version: value.version?, @@ -4392,7 +4710,7 @@ pub mod types { impl std::convert::TryFrom for super::Error { type Error = String; - fn try_from(value: Error) -> Result { + fn try_from(value: Error) -> Result { Ok(Self { error_code: value.error_code?, message: value.message?, @@ -4440,7 +4758,7 @@ pub mod types { impl std::convert::TryFrom for super::ExternalIp { type Error = String; - fn try_from(value: ExternalIp) -> Result { + fn try_from(value: ExternalIp) -> Result { Ok(Self { ip: value.ip?, kind: value.kind?, @@ -4487,7 +4805,7 @@ pub mod types { impl std::convert::TryFrom for super::ExternalIpResultsPage { type Error = String; - fn try_from(value: ExternalIpResultsPage) -> Result { + fn try_from(value: ExternalIpResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -4546,7 +4864,7 @@ pub mod types { impl std::convert::TryFrom for super::FieldSchema { type Error = String; - fn try_from(value: FieldSchema) -> Result { + fn try_from(value: FieldSchema) -> Result { Ok(Self { name: value.name?, source: value.source?, @@ -4585,7 +4903,7 @@ pub mod types { impl std::convert::TryFrom for super::FleetRolePolicy { type Error = String; - fn try_from(value: FleetRolePolicy) -> Result { + fn try_from(value: FleetRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -4643,7 +4961,7 @@ pub mod types { impl std::convert::TryFrom for super::FleetRoleRoleAssignment { type Error = String; - fn try_from(value: FleetRoleRoleAssignment) -> Result { + fn try_from(value: FleetRoleRoleAssignment) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -4799,7 +5117,7 @@ pub mod types { impl std::convert::TryFrom for super::GlobalImage { type Error = String; - fn try_from(value: GlobalImage) -> Result { + fn try_from(value: GlobalImage) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -4891,7 +5209,7 @@ pub mod types { impl std::convert::TryFrom for super::GlobalImageCreate { type Error = String; - fn try_from(value: GlobalImageCreate) -> Result { + fn try_from(value: GlobalImageCreate) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -4941,7 +5259,7 @@ pub mod types { impl std::convert::TryFrom for super::GlobalImageResultsPage { type Error = String; - fn try_from(value: GlobalImageResultsPage) -> Result { + fn try_from(value: GlobalImageResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -5000,7 +5318,7 @@ pub mod types { impl std::convert::TryFrom for super::Histogramdouble { type Error = String; - fn try_from(value: Histogramdouble) -> Result { + fn try_from(value: Histogramdouble) -> Result { Ok(Self { bins: value.bins?, n_samples: value.n_samples?, @@ -5060,7 +5378,7 @@ pub mod types { impl std::convert::TryFrom for super::Histogramint64 { type Error = String; - fn try_from(value: Histogramint64) -> Result { + fn try_from(value: Histogramint64) -> Result { Ok(Self { bins: value.bins?, n_samples: value.n_samples?, @@ -5156,7 +5474,7 @@ pub mod types { impl std::convert::TryFrom for super::IdentityProvider { type Error = String; - fn try_from(value: IdentityProvider) -> Result { + fn try_from(value: IdentityProvider) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -5207,7 +5525,7 @@ pub mod types { impl std::convert::TryFrom for super::IdentityProviderResultsPage { type Error = String; - fn try_from(value: IdentityProviderResultsPage) -> Result { + fn try_from(value: IdentityProviderResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -5362,7 +5680,7 @@ pub mod types { impl std::convert::TryFrom for super::Image { type Error = String; - fn try_from(value: Image) -> Result { + fn try_from(value: Image) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -5442,7 +5760,7 @@ pub mod types { impl std::convert::TryFrom for super::ImageCreate { type Error = String; - fn try_from(value: ImageCreate) -> Result { + fn try_from(value: ImageCreate) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -5491,7 +5809,7 @@ pub mod types { impl std::convert::TryFrom for super::ImageResultsPage { type Error = String; - fn try_from(value: ImageResultsPage) -> Result { + fn try_from(value: ImageResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -5651,7 +5969,7 @@ pub mod types { impl std::convert::TryFrom for super::Instance { type Error = String; - fn try_from(value: Instance) -> Result { + fn try_from(value: Instance) -> Result { Ok(Self { description: value.description?, hostname: value.hostname?, @@ -5794,7 +6112,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceCreate { type Error = String; - fn try_from(value: InstanceCreate) -> Result { + fn try_from(value: InstanceCreate) -> Result { Ok(Self { description: value.description?, disks: value.disks?, @@ -5836,7 +6154,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceMigrate { type Error = String; - fn try_from(value: InstanceMigrate) -> Result { + fn try_from(value: InstanceMigrate) -> Result { Ok(Self { dst_sled_id: value.dst_sled_id?, }) @@ -5882,7 +6200,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceResultsPage { type Error = String; - fn try_from(value: InstanceResultsPage) -> Result { + fn try_from(value: InstanceResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -5932,7 +6250,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceSerialConsoleData { type Error = String; - fn try_from(value: InstanceSerialConsoleData) -> Result { + fn try_from(value: InstanceSerialConsoleData) -> Result { Ok(Self { data: value.data?, last_byte_offset: value.last_byte_offset?, @@ -6027,7 +6345,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPool { type Error = String; - fn try_from(value: IpPool) -> Result { + fn try_from(value: IpPool) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -6102,7 +6420,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPoolCreate { type Error = String; - fn try_from(value: IpPoolCreate) -> Result { + fn try_from(value: IpPoolCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -6163,7 +6481,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPoolRange { type Error = String; - fn try_from(value: IpPoolRange) -> Result { + fn try_from(value: IpPoolRange) -> Result { Ok(Self { id: value.id?, range: value.range?, @@ -6211,7 +6529,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPoolRangeResultsPage { type Error = String; - fn try_from(value: IpPoolRangeResultsPage) -> Result { + fn try_from(value: IpPoolRangeResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -6258,7 +6576,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPoolResultsPage { type Error = String; - fn try_from(value: IpPoolResultsPage) -> Result { + fn try_from(value: IpPoolResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -6305,7 +6623,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPoolUpdate { type Error = String; - fn try_from(value: IpPoolUpdate) -> Result { + fn try_from(value: IpPoolUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -6352,7 +6670,7 @@ pub mod types { impl std::convert::TryFrom for super::Ipv4Range { type Error = String; - fn try_from(value: Ipv4Range) -> Result { + fn try_from(value: Ipv4Range) -> Result { Ok(Self { first: value.first?, last: value.last?, @@ -6399,7 +6717,7 @@ pub mod types { impl std::convert::TryFrom for super::Ipv6Range { type Error = String; - fn try_from(value: Ipv6Range) -> Result { + fn try_from(value: Ipv6Range) -> Result { Ok(Self { first: value.first?, last: value.last?, @@ -6446,7 +6764,7 @@ pub mod types { impl std::convert::TryFrom for super::Measurement { type Error = String; - fn try_from(value: Measurement) -> Result { + fn try_from(value: Measurement) -> Result { Ok(Self { datum: value.datum?, timestamp: value.timestamp?, @@ -6493,7 +6811,7 @@ pub mod types { impl std::convert::TryFrom for super::MeasurementResultsPage { type Error = String; - fn try_from(value: MeasurementResultsPage) -> Result { + fn try_from(value: MeasurementResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -6648,7 +6966,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterface { type Error = String; - fn try_from(value: NetworkInterface) -> Result { + fn try_from(value: NetworkInterface) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -6740,7 +7058,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterfaceCreate { type Error = String; - fn try_from(value: NetworkInterfaceCreate) -> Result { + fn try_from(value: NetworkInterfaceCreate) -> Result { Ok(Self { description: value.description?, ip: value.ip?, @@ -6790,7 +7108,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterfaceResultsPage { type Error = String; - fn try_from(value: NetworkInterfaceResultsPage) -> Result { + fn try_from(value: NetworkInterfaceResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -6849,7 +7167,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterfaceUpdate { type Error = String; - fn try_from(value: NetworkInterfaceUpdate) -> Result { + fn try_from(value: NetworkInterfaceUpdate) -> Result { Ok(Self { description: value.description?, make_primary: value.make_primary?, @@ -6933,7 +7251,7 @@ pub mod types { impl std::convert::TryFrom for super::Organization { type Error = String; - fn try_from(value: Organization) -> Result { + fn try_from(value: Organization) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -6983,7 +7301,7 @@ pub mod types { impl std::convert::TryFrom for super::OrganizationCreate { type Error = String; - fn try_from(value: OrganizationCreate) -> Result { + fn try_from(value: OrganizationCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -7030,7 +7348,7 @@ pub mod types { impl std::convert::TryFrom for super::OrganizationResultsPage { type Error = String; - fn try_from(value: OrganizationResultsPage) -> Result { + fn try_from(value: OrganizationResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -7068,7 +7386,7 @@ pub mod types { impl std::convert::TryFrom for super::OrganizationRolePolicy { type Error = String; - fn try_from(value: OrganizationRolePolicy) -> Result { + fn try_from(value: OrganizationRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -7128,7 +7446,7 @@ pub mod types { for super::OrganizationRoleRoleAssignment { type Error = String; - fn try_from(value: OrganizationRoleRoleAssignment) -> Result { + fn try_from(value: OrganizationRoleRoleAssignment) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -7176,7 +7494,7 @@ pub mod types { impl std::convert::TryFrom for super::OrganizationUpdate { type Error = String; - fn try_from(value: OrganizationUpdate) -> Result { + fn try_from(value: OrganizationUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -7271,7 +7589,7 @@ pub mod types { impl std::convert::TryFrom for super::Project { type Error = String; - fn try_from(value: Project) -> Result { + fn try_from(value: Project) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -7322,7 +7640,7 @@ pub mod types { impl std::convert::TryFrom for super::ProjectCreate { type Error = String; - fn try_from(value: ProjectCreate) -> Result { + fn try_from(value: ProjectCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -7369,7 +7687,7 @@ pub mod types { impl std::convert::TryFrom for super::ProjectResultsPage { type Error = String; - fn try_from(value: ProjectResultsPage) -> Result { + fn try_from(value: ProjectResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -7407,7 +7725,7 @@ pub mod types { impl std::convert::TryFrom for super::ProjectRolePolicy { type Error = String; - fn try_from(value: ProjectRolePolicy) -> Result { + fn try_from(value: ProjectRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -7465,7 +7783,7 @@ pub mod types { impl std::convert::TryFrom for super::ProjectRoleRoleAssignment { type Error = String; - fn try_from(value: ProjectRoleRoleAssignment) -> Result { + fn try_from(value: ProjectRoleRoleAssignment) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -7513,7 +7831,7 @@ pub mod types { impl std::convert::TryFrom for super::ProjectUpdate { type Error = String; - fn try_from(value: ProjectUpdate) -> Result { + fn try_from(value: ProjectUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -7572,7 +7890,7 @@ pub mod types { impl std::convert::TryFrom for super::Rack { type Error = String; - fn try_from(value: Rack) -> Result { + fn try_from(value: Rack) -> Result { Ok(Self { id: value.id?, time_created: value.time_created?, @@ -7620,7 +7938,7 @@ pub mod types { impl std::convert::TryFrom for super::RackResultsPage { type Error = String; - fn try_from(value: RackResultsPage) -> Result { + fn try_from(value: RackResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -7667,7 +7985,7 @@ pub mod types { impl std::convert::TryFrom for super::Role { type Error = String; - fn try_from(value: Role) -> Result { + fn try_from(value: Role) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -7714,7 +8032,7 @@ pub mod types { impl std::convert::TryFrom for super::RoleResultsPage { type Error = String; - fn try_from(value: RoleResultsPage) -> Result { + fn try_from(value: RoleResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -7845,7 +8163,7 @@ pub mod types { impl std::convert::TryFrom for super::RouterRoute { type Error = String; - fn try_from(value: RouterRoute) -> Result { + fn try_from(value: RouterRoute) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -7923,7 +8241,7 @@ pub mod types { impl std::convert::TryFrom for super::RouterRouteCreateParams { type Error = String; - fn try_from(value: RouterRouteCreateParams) -> Result { + fn try_from(value: RouterRouteCreateParams) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -7972,7 +8290,7 @@ pub mod types { impl std::convert::TryFrom for super::RouterRouteResultsPage { type Error = String; - fn try_from(value: RouterRouteResultsPage) -> Result { + fn try_from(value: RouterRouteResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -8043,7 +8361,7 @@ pub mod types { impl std::convert::TryFrom for super::RouterRouteUpdateParams { type Error = String; - fn try_from(value: RouterRouteUpdateParams) -> Result { + fn try_from(value: RouterRouteUpdateParams) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -8092,7 +8410,7 @@ pub mod types { impl std::convert::TryFrom for super::Saga { type Error = String; - fn try_from(value: Saga) -> Result { + fn try_from(value: Saga) -> Result { Ok(Self { id: value.id?, state: value.state?, @@ -8139,7 +8457,7 @@ pub mod types { impl std::convert::TryFrom for super::SagaResultsPage { type Error = String; - fn try_from(value: SagaResultsPage) -> Result { + fn try_from(value: SagaResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -8299,7 +8617,7 @@ pub mod types { impl std::convert::TryFrom for super::SamlIdentityProvider { type Error = String; - fn try_from(value: SamlIdentityProvider) -> Result { + fn try_from(value: SamlIdentityProvider) -> Result { Ok(Self { acs_url: value.acs_url?, description: value.description?, @@ -8449,7 +8767,7 @@ pub mod types { impl std::convert::TryFrom for super::SamlIdentityProviderCreate { type Error = String; - fn try_from(value: SamlIdentityProviderCreate) -> Result { + fn try_from(value: SamlIdentityProviderCreate) -> Result { Ok(Self { acs_url: value.acs_url?, description: value.description?, @@ -8568,7 +8886,7 @@ pub mod types { impl std::convert::TryFrom for super::Silo { type Error = String; - fn try_from(value: Silo) -> Result { + fn try_from(value: Silo) -> Result { Ok(Self { description: value.description?, discoverable: value.discoverable?, @@ -8649,7 +8967,7 @@ pub mod types { impl std::convert::TryFrom for super::SiloCreate { type Error = String; - fn try_from(value: SiloCreate) -> Result { + fn try_from(value: SiloCreate) -> Result { Ok(Self { description: value.description?, discoverable: value.discoverable?, @@ -8698,7 +9016,7 @@ pub mod types { impl std::convert::TryFrom for super::SiloResultsPage { type Error = String; - fn try_from(value: SiloResultsPage) -> Result { + fn try_from(value: SiloResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -8736,7 +9054,7 @@ pub mod types { impl std::convert::TryFrom for super::SiloRolePolicy { type Error = String; - fn try_from(value: SiloRolePolicy) -> Result { + fn try_from(value: SiloRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -8794,7 +9112,7 @@ pub mod types { impl std::convert::TryFrom for super::SiloRoleRoleAssignment { type Error = String; - fn try_from(value: SiloRoleRoleAssignment) -> Result { + fn try_from(value: SiloRoleRoleAssignment) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -8866,7 +9184,7 @@ pub mod types { impl std::convert::TryFrom for super::Sled { type Error = String; - fn try_from(value: Sled) -> Result { + fn try_from(value: Sled) -> Result { Ok(Self { id: value.id?, service_address: value.service_address?, @@ -8915,7 +9233,7 @@ pub mod types { impl std::convert::TryFrom for super::SledResultsPage { type Error = String; - fn try_from(value: SledResultsPage) -> Result { + fn try_from(value: SledResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9034,7 +9352,7 @@ pub mod types { impl std::convert::TryFrom for super::Snapshot { type Error = String; - fn try_from(value: Snapshot) -> Result { + fn try_from(value: Snapshot) -> Result { Ok(Self { description: value.description?, disk_id: value.disk_id?, @@ -9099,7 +9417,7 @@ pub mod types { impl std::convert::TryFrom for super::SnapshotCreate { type Error = String; - fn try_from(value: SnapshotCreate) -> Result { + fn try_from(value: SnapshotCreate) -> Result { Ok(Self { description: value.description?, disk: value.disk?, @@ -9147,7 +9465,7 @@ pub mod types { impl std::convert::TryFrom for super::SnapshotResultsPage { type Error = String; - fn try_from(value: SnapshotResultsPage) -> Result { + fn try_from(value: SnapshotResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9182,7 +9500,7 @@ pub mod types { impl std::convert::TryFrom for super::SpoofLoginBody { type Error = String; - fn try_from(value: SpoofLoginBody) -> Result { + fn try_from(value: SpoofLoginBody) -> Result { Ok(Self { username: value.username?, }) @@ -9288,7 +9606,7 @@ pub mod types { impl std::convert::TryFrom for super::SshKey { type Error = String; - fn try_from(value: SshKey) -> Result { + fn try_from(value: SshKey) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -9352,7 +9670,7 @@ pub mod types { impl std::convert::TryFrom for super::SshKeyCreate { type Error = String; - fn try_from(value: SshKeyCreate) -> Result { + fn try_from(value: SshKeyCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -9400,7 +9718,7 @@ pub mod types { impl std::convert::TryFrom for super::SshKeyResultsPage { type Error = String; - fn try_from(value: SshKeyResultsPage) -> Result { + fn try_from(value: SshKeyResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9471,7 +9789,7 @@ pub mod types { impl std::convert::TryFrom for super::TimeseriesSchema { type Error = String; - fn try_from(value: TimeseriesSchema) -> Result { + fn try_from(value: TimeseriesSchema) -> Result { Ok(Self { created: value.created?, datum_type: value.datum_type?, @@ -9520,7 +9838,7 @@ pub mod types { impl std::convert::TryFrom for super::TimeseriesSchemaResultsPage { type Error = String; - fn try_from(value: TimeseriesSchemaResultsPage) -> Result { + fn try_from(value: TimeseriesSchemaResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9567,7 +9885,7 @@ pub mod types { impl std::convert::TryFrom for super::User { type Error = String; - fn try_from(value: User) -> Result { + fn try_from(value: User) -> Result { Ok(Self { display_name: value.display_name?, id: value.id?, @@ -9650,7 +9968,7 @@ pub mod types { impl std::convert::TryFrom for super::UserBuiltin { type Error = String; - fn try_from(value: UserBuiltin) -> Result { + fn try_from(value: UserBuiltin) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -9700,7 +10018,7 @@ pub mod types { impl std::convert::TryFrom for super::UserBuiltinResultsPage { type Error = String; - fn try_from(value: UserBuiltinResultsPage) -> Result { + fn try_from(value: UserBuiltinResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9747,7 +10065,7 @@ pub mod types { impl std::convert::TryFrom for super::UserResultsPage { type Error = String; - fn try_from(value: UserResultsPage) -> Result { + fn try_from(value: UserResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9881,7 +10199,7 @@ pub mod types { impl std::convert::TryFrom for super::Vpc { type Error = String; - fn try_from(value: Vpc) -> Result { + fn try_from(value: Vpc) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, @@ -9959,7 +10277,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcCreate { type Error = String; - fn try_from(value: VpcCreate) -> Result { + fn try_from(value: VpcCreate) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, @@ -10128,7 +10446,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcFirewallRule { type Error = String; - fn try_from(value: VpcFirewallRule) -> Result { + fn try_from(value: VpcFirewallRule) -> Result { Ok(Self { action: value.action?, description: value.description?, @@ -10197,7 +10515,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcFirewallRuleFilter { type Error = String; - fn try_from(value: VpcFirewallRuleFilter) -> Result { + fn try_from(value: VpcFirewallRuleFilter) -> Result { Ok(Self { hosts: value.hosts?, ports: value.ports?, @@ -10317,7 +10635,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcFirewallRuleUpdate { type Error = String; - fn try_from(value: VpcFirewallRuleUpdate) -> Result { + fn try_from(value: VpcFirewallRuleUpdate) -> Result { Ok(Self { action: value.action?, description: value.description?, @@ -10358,7 +10676,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcFirewallRuleUpdateParams { type Error = String; - fn try_from(value: VpcFirewallRuleUpdateParams) -> Result { + fn try_from(value: VpcFirewallRuleUpdateParams) -> Result { Ok(Self { rules: value.rules?, }) @@ -10392,7 +10710,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcFirewallRules { type Error = String; - fn try_from(value: VpcFirewallRules) -> Result { + fn try_from(value: VpcFirewallRules) -> Result { Ok(Self { rules: value.rules?, }) @@ -10438,7 +10756,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcResultsPage { type Error = String; - fn try_from(value: VpcResultsPage) -> Result { + fn try_from(value: VpcResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -10545,7 +10863,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcRouter { type Error = String; - fn try_from(value: VpcRouter) -> Result { + fn try_from(value: VpcRouter) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -10597,7 +10915,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcRouterCreate { type Error = String; - fn try_from(value: VpcRouterCreate) -> Result { + fn try_from(value: VpcRouterCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -10644,7 +10962,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcRouterResultsPage { type Error = String; - fn try_from(value: VpcRouterResultsPage) -> Result { + fn try_from(value: VpcRouterResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -10691,7 +11009,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcRouterUpdate { type Error = String; - fn try_from(value: VpcRouterUpdate) -> Result { + fn try_from(value: VpcRouterUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -10810,7 +11128,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcSubnet { type Error = String; - fn try_from(value: VpcSubnet) -> Result { + fn try_from(value: VpcSubnet) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -10887,7 +11205,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcSubnetCreate { type Error = String; - fn try_from(value: VpcSubnetCreate) -> Result { + fn try_from(value: VpcSubnetCreate) -> Result { Ok(Self { description: value.description?, ipv4_block: value.ipv4_block?, @@ -10936,7 +11254,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcSubnetResultsPage { type Error = String; - fn try_from(value: VpcSubnetResultsPage) -> Result { + fn try_from(value: VpcSubnetResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -10983,7 +11301,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcSubnetUpdate { type Error = String; - fn try_from(value: VpcSubnetUpdate) -> Result { + fn try_from(value: VpcSubnetUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -11042,7 +11360,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcUpdate { type Error = String; - fn try_from(value: VpcUpdate) -> Result { + fn try_from(value: VpcUpdate) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, diff --git a/progenitor-impl/tests/output/nexus-builder.out b/progenitor-impl/tests/output/nexus-builder.out index 6c0501d..7a16d8e 100644 --- a/progenitor-impl/tests/output/nexus-builder.out +++ b/progenitor-impl/tests/output/nexus-builder.out @@ -81,14 +81,14 @@ pub mod types { pub struct BlockSize(i64); impl std::ops::Deref for BlockSize { type Target = i64; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &i64 { &self.0 } } impl std::convert::TryFrom for BlockSize { type Error = &'static str; - fn try_from(value: i64) -> Result { + fn try_from(value: i64) -> Result { if ![512_i64, 2048_i64, 4096_i64].contains(&value) { Err("invalid value") } else { @@ -108,7 +108,7 @@ pub mod types { pub struct ByteCount(pub u64); impl std::ops::Deref for ByteCount { type Target = u64; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &u64 { &self.0 } } @@ -206,7 +206,7 @@ pub mod types { impl std::str::FromStr for DatumType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "bool" => Ok(Self::Bool), "i64" => Ok(Self::I64), @@ -222,6 +222,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for DatumType { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct DerEncodedKeyPair { ///request signing private key (base64 encoded der file) @@ -372,7 +386,7 @@ pub mod types { impl std::str::FromStr for DiskMetricName { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "activated" => Ok(Self::Activated), "flush" => Ok(Self::Flush), @@ -385,6 +399,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for DiskMetricName { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct DiskResultsPage { @@ -554,7 +582,7 @@ pub mod types { impl std::str::FromStr for FieldSource { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "target" => Ok(Self::Target), "metric" => Ok(Self::Metric), @@ -563,6 +591,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for FieldSource { + type Error = &'static str; + 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 { + value.parse() + } + } + ///The `FieldType` identifies the data type of a target or metric field. #[derive( Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, @@ -594,7 +636,7 @@ pub mod types { impl std::str::FromStr for FieldType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "string" => Ok(Self::String), "i64" => Ok(Self::I64), @@ -606,6 +648,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for FieldType { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive( Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, )] @@ -630,7 +686,7 @@ pub mod types { impl std::str::FromStr for FleetRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -640,6 +696,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for FleetRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -879,7 +949,7 @@ pub mod types { impl std::str::FromStr for IdSortMode { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "id_ascending" => Ok(Self::IdAscending), _ => Err("invalid value"), @@ -887,6 +957,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IdSortMode { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of an [`IdentityProvider`] #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct IdentityProvider { @@ -944,7 +1028,7 @@ pub mod types { impl std::str::FromStr for IdentityProviderType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "saml" => Ok(Self::Saml), _ => Err("invalid value"), @@ -952,6 +1036,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IdentityProviderType { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Describes what kind of identity is described by an id #[derive( Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, @@ -971,7 +1069,7 @@ pub mod types { impl std::str::FromStr for IdentityType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "silo_user" => Ok(Self::SiloUser), _ => Err("invalid value"), @@ -979,6 +1077,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IdentityType { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] #[serde(tag = "type")] pub enum IdpMetadataSource { @@ -1106,7 +1218,7 @@ pub mod types { pub struct InstanceCpuCount(pub u16); impl std::ops::Deref for InstanceCpuCount { type Target = u16; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &u16 { &self.0 } } @@ -1282,7 +1394,7 @@ pub mod types { impl std::str::FromStr for InstanceState { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "creating" => Ok(Self::Creating), "starting" => Ok(Self::Starting), @@ -1299,6 +1411,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for InstanceState { + type Error = &'static str; + 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 { + value.parse() + } + } + ///The kind of an external IP address for an instance #[derive( Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, @@ -1321,7 +1447,7 @@ pub mod types { impl std::str::FromStr for IpKind { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "ephemeral" => Ok(Self::Ephemeral), "floating" => Ok(Self::Floating), @@ -1330,6 +1456,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IpKind { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] #[serde(untagged)] pub enum IpNet { @@ -1337,27 +1477,30 @@ pub mod types { V6(Ipv6Net), } + impl std::str::FromStr for IpNet { + type Err = &'static str; + 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") + } + } + } + impl std::convert::TryFrom<&str> for IpNet { type Error = &'static str; - fn try_from(value: &str) -> Result { - Err("") - .or_else(|_: Self::Error| Ok(Self::V4(Ipv4Net::try_from(value)?))) - .or_else(|_: Self::Error| Ok(Self::V6(Ipv6Net::try_from(value)?))) - .map_err(|_: Self::Error| "string conversion failed for all variants") + 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 { - Self::try_from(value.as_str()) - } - } - - impl std::convert::TryFrom for IpNet { - type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1485,30 +1628,30 @@ pub mod types { pub struct Ipv4Net(String); impl std::ops::Deref for Ipv4Net { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for Ipv4Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for Ipv4Net { + type Err = &'static str; + fn from_str(value: &str) -> Result { if regress :: Regex :: new ("^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([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])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([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])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$\"") ; } Ok(Self(value.to_string())) } } - impl std::convert::TryFrom<&String> for Ipv4Net { + impl std::convert::TryFrom<&str> for Ipv4Net { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for Ipv4Net { + impl std::convert::TryFrom<&String> for Ipv4Net { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1517,8 +1660,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1542,30 +1686,30 @@ pub mod types { pub struct Ipv6Net(String); impl std::ops::Deref for Ipv6Net { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for Ipv6Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for Ipv6Net { + type Err = &'static str; + 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])$") . unwrap () . find (value) . is_none () { 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])$\"") ; } Ok(Self(value.to_string())) } } - impl std::convert::TryFrom<&String> for Ipv6Net { + impl std::convert::TryFrom<&str> for Ipv6Net { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for Ipv6Net { + impl std::convert::TryFrom<&String> for Ipv6Net { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1574,8 +1718,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1600,14 +1745,14 @@ pub mod types { pub struct L4PortRange(String); impl std::ops::Deref for L4PortRange { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for L4PortRange { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for L4PortRange { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 11usize { return Err("longer than 11 characters"); } @@ -1625,17 +1770,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for L4PortRange { + impl std::convert::TryFrom<&str> for L4PortRange { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for L4PortRange { + impl std::convert::TryFrom<&String> for L4PortRange { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1644,8 +1789,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1654,14 +1800,14 @@ pub mod types { pub struct MacAddr(String); impl std::ops::Deref for MacAddr { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for MacAddr { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for MacAddr { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 17usize { return Err("longer than 17 characters"); } @@ -1679,17 +1825,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for MacAddr { + impl std::convert::TryFrom<&str> for MacAddr { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for MacAddr { + impl std::convert::TryFrom<&String> for MacAddr { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1698,8 +1844,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1739,14 +1886,14 @@ pub mod types { pub struct Name(String); impl std::ops::Deref for Name { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for Name { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for Name { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 63usize { return Err("longer than 63 characters"); } @@ -1755,17 +1902,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for Name { + impl std::convert::TryFrom<&str> for Name { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for Name { + impl std::convert::TryFrom<&String> for Name { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1774,8 +1921,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1804,7 +1952,7 @@ pub mod types { impl std::str::FromStr for NameOrIdSortMode { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), "name_descending" => Ok(Self::NameDescending), @@ -1814,6 +1962,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for NameOrIdSortMode { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Supported set of sort modes for scanning by name only /// ///Currently, we only support scanning in ascending order. @@ -1835,7 +1997,7 @@ pub mod types { impl std::str::FromStr for NameSortMode { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), _ => Err("invalid value"), @@ -1843,6 +2005,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for NameSortMode { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A `NetworkInterface` represents a virtual network interface device. #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct NetworkInterface { @@ -2022,7 +2198,7 @@ pub mod types { impl std::str::FromStr for OrganizationRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -2032,6 +2208,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for OrganizationRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -2161,7 +2351,7 @@ pub mod types { impl std::str::FromStr for ProjectRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -2171,6 +2361,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for ProjectRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -2275,14 +2479,14 @@ pub mod types { pub struct RoleName(String); impl std::ops::Deref for RoleName { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for RoleName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for RoleName { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 63usize { return Err("longer than 63 characters"); } @@ -2297,17 +2501,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for RoleName { + impl std::convert::TryFrom<&str> for RoleName { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for RoleName { + impl std::convert::TryFrom<&String> for RoleName { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -2316,8 +2520,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -2457,7 +2662,7 @@ pub mod types { impl std::str::FromStr for RouterRouteKind { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "default" => Ok(Self::Default), "vpc_subnet" => Ok(Self::VpcSubnet), @@ -2468,6 +2673,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for RouterRouteKind { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct RouterRouteResultsPage { @@ -2703,7 +2922,7 @@ pub mod types { impl std::str::FromStr for SiloRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -2713,6 +2932,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for SiloRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -2915,14 +3148,14 @@ pub mod types { pub struct TimeseriesName(String); impl std::ops::Deref for TimeseriesName { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for TimeseriesName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for TimeseriesName { + type Err = &'static str; + 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]+))*)", ) @@ -2936,17 +3169,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for TimeseriesName { + impl std::convert::TryFrom<&str> for TimeseriesName { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for TimeseriesName { + impl std::convert::TryFrom<&String> for TimeseriesName { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -2955,8 +3188,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -3067,7 +3301,7 @@ pub mod types { impl std::str::FromStr for UserProvisionType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "fixed" => Ok(Self::Fixed), "jit" => Ok(Self::Jit), @@ -3076,6 +3310,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for UserProvisionType { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for UserProvisionType { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct UserResultsPage { @@ -3199,7 +3447,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleAction { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "allow" => Ok(Self::Allow), "deny" => Ok(Self::Deny), @@ -3208,6 +3456,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleAction { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive( Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, )] @@ -3229,7 +3491,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleDirection { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "inbound" => Ok(Self::Inbound), "outbound" => Ok(Self::Outbound), @@ -3238,6 +3500,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleDirection { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Filter for a firewall rule. A given packet must match every field that /// is present for the rule to apply to it. A packet matches a field if any /// entry in that field matches the packet. @@ -3308,7 +3584,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleProtocol { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "TCP" => Ok(Self::Tcp), "UDP" => Ok(Self::Udp), @@ -3318,6 +3594,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleProtocol { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive( Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, )] @@ -3339,7 +3629,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleStatus { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "disabled" => Ok(Self::Disabled), "enabled" => Ok(Self::Enabled), @@ -3348,6 +3638,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleStatus { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to /// which a firewall rule applies. #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] @@ -3499,7 +3803,7 @@ pub mod types { impl std::str::FromStr for VpcRouterKind { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "system" => Ok(Self::System), "custom" => Ok(Self::Custom), @@ -3508,6 +3812,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcRouterKind { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct VpcRouterResultsPage { @@ -3685,7 +4003,7 @@ pub mod types { impl std::convert::TryFrom for super::Bindouble { type Error = String; - fn try_from(value: Bindouble) -> Result { + fn try_from(value: Bindouble) -> Result { Ok(Self { count: value.count?, range: value.range?, @@ -3732,7 +4050,7 @@ pub mod types { impl std::convert::TryFrom for super::Binint64 { type Error = String; - fn try_from(value: Binint64) -> Result { + fn try_from(value: Binint64) -> Result { Ok(Self { count: value.count?, range: value.range?, @@ -3779,7 +4097,7 @@ pub mod types { impl std::convert::TryFrom for super::Cumulativedouble { type Error = String; - fn try_from(value: Cumulativedouble) -> Result { + fn try_from(value: Cumulativedouble) -> Result { Ok(Self { start_time: value.start_time?, value: value.value?, @@ -3826,7 +4144,7 @@ pub mod types { impl std::convert::TryFrom for super::Cumulativeint64 { type Error = String; - fn try_from(value: Cumulativeint64) -> Result { + fn try_from(value: Cumulativeint64) -> Result { Ok(Self { start_time: value.start_time?, value: value.value?, @@ -3873,7 +4191,7 @@ pub mod types { impl std::convert::TryFrom for super::DerEncodedKeyPair { type Error = String; - fn try_from(value: DerEncodedKeyPair) -> Result { + fn try_from(value: DerEncodedKeyPair) -> Result { Ok(Self { private_key: value.private_key?, public_cert: value.public_cert?, @@ -3932,7 +4250,7 @@ pub mod types { impl std::convert::TryFrom for super::DeviceAccessTokenRequest { type Error = String; - fn try_from(value: DeviceAccessTokenRequest) -> Result { + fn try_from(value: DeviceAccessTokenRequest) -> Result { Ok(Self { client_id: value.client_id?, device_code: value.device_code?, @@ -3968,7 +4286,7 @@ pub mod types { impl std::convert::TryFrom for super::DeviceAuthRequest { type Error = String; - fn try_from(value: DeviceAuthRequest) -> Result { + fn try_from(value: DeviceAuthRequest) -> Result { Ok(Self { client_id: value.client_id?, }) @@ -4002,7 +4320,7 @@ pub mod types { impl std::convert::TryFrom for super::DeviceAuthVerify { type Error = String; - fn try_from(value: DeviceAuthVerify) -> Result { + fn try_from(value: DeviceAuthVerify) -> Result { Ok(Self { user_code: value.user_code?, }) @@ -4168,7 +4486,7 @@ pub mod types { impl std::convert::TryFrom for super::Disk { type Error = String; - fn try_from(value: Disk) -> Result { + fn try_from(value: Disk) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -4249,7 +4567,7 @@ pub mod types { impl std::convert::TryFrom for super::DiskCreate { type Error = String; - fn try_from(value: DiskCreate) -> Result { + fn try_from(value: DiskCreate) -> Result { Ok(Self { description: value.description?, disk_source: value.disk_source?, @@ -4286,7 +4604,7 @@ pub mod types { impl std::convert::TryFrom for super::DiskIdentifier { type Error = String; - fn try_from(value: DiskIdentifier) -> Result { + fn try_from(value: DiskIdentifier) -> Result { Ok(Self { name: value.name? }) } } @@ -4330,7 +4648,7 @@ pub mod types { impl std::convert::TryFrom for super::DiskResultsPage { type Error = String; - fn try_from(value: DiskResultsPage) -> Result { + fn try_from(value: DiskResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -4377,7 +4695,7 @@ pub mod types { impl std::convert::TryFrom for super::Distribution { type Error = String; - fn try_from(value: Distribution) -> Result { + fn try_from(value: Distribution) -> Result { Ok(Self { name: value.name?, version: value.version?, @@ -4436,7 +4754,7 @@ pub mod types { impl std::convert::TryFrom for super::Error { type Error = String; - fn try_from(value: Error) -> Result { + fn try_from(value: Error) -> Result { Ok(Self { error_code: value.error_code?, message: value.message?, @@ -4484,7 +4802,7 @@ pub mod types { impl std::convert::TryFrom for super::ExternalIp { type Error = String; - fn try_from(value: ExternalIp) -> Result { + fn try_from(value: ExternalIp) -> Result { Ok(Self { ip: value.ip?, kind: value.kind?, @@ -4531,7 +4849,7 @@ pub mod types { impl std::convert::TryFrom for super::ExternalIpResultsPage { type Error = String; - fn try_from(value: ExternalIpResultsPage) -> Result { + fn try_from(value: ExternalIpResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -4590,7 +4908,7 @@ pub mod types { impl std::convert::TryFrom for super::FieldSchema { type Error = String; - fn try_from(value: FieldSchema) -> Result { + fn try_from(value: FieldSchema) -> Result { Ok(Self { name: value.name?, source: value.source?, @@ -4629,7 +4947,7 @@ pub mod types { impl std::convert::TryFrom for super::FleetRolePolicy { type Error = String; - fn try_from(value: FleetRolePolicy) -> Result { + fn try_from(value: FleetRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -4687,7 +5005,7 @@ pub mod types { impl std::convert::TryFrom for super::FleetRoleRoleAssignment { type Error = String; - fn try_from(value: FleetRoleRoleAssignment) -> Result { + fn try_from(value: FleetRoleRoleAssignment) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -4843,7 +5161,7 @@ pub mod types { impl std::convert::TryFrom for super::GlobalImage { type Error = String; - fn try_from(value: GlobalImage) -> Result { + fn try_from(value: GlobalImage) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -4935,7 +5253,7 @@ pub mod types { impl std::convert::TryFrom for super::GlobalImageCreate { type Error = String; - fn try_from(value: GlobalImageCreate) -> Result { + fn try_from(value: GlobalImageCreate) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -4985,7 +5303,7 @@ pub mod types { impl std::convert::TryFrom for super::GlobalImageResultsPage { type Error = String; - fn try_from(value: GlobalImageResultsPage) -> Result { + fn try_from(value: GlobalImageResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -5044,7 +5362,7 @@ pub mod types { impl std::convert::TryFrom for super::Histogramdouble { type Error = String; - fn try_from(value: Histogramdouble) -> Result { + fn try_from(value: Histogramdouble) -> Result { Ok(Self { bins: value.bins?, n_samples: value.n_samples?, @@ -5104,7 +5422,7 @@ pub mod types { impl std::convert::TryFrom for super::Histogramint64 { type Error = String; - fn try_from(value: Histogramint64) -> Result { + fn try_from(value: Histogramint64) -> Result { Ok(Self { bins: value.bins?, n_samples: value.n_samples?, @@ -5200,7 +5518,7 @@ pub mod types { impl std::convert::TryFrom for super::IdentityProvider { type Error = String; - fn try_from(value: IdentityProvider) -> Result { + fn try_from(value: IdentityProvider) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -5251,7 +5569,7 @@ pub mod types { impl std::convert::TryFrom for super::IdentityProviderResultsPage { type Error = String; - fn try_from(value: IdentityProviderResultsPage) -> Result { + fn try_from(value: IdentityProviderResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -5406,7 +5724,7 @@ pub mod types { impl std::convert::TryFrom for super::Image { type Error = String; - fn try_from(value: Image) -> Result { + fn try_from(value: Image) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -5486,7 +5804,7 @@ pub mod types { impl std::convert::TryFrom for super::ImageCreate { type Error = String; - fn try_from(value: ImageCreate) -> Result { + fn try_from(value: ImageCreate) -> Result { Ok(Self { block_size: value.block_size?, description: value.description?, @@ -5535,7 +5853,7 @@ pub mod types { impl std::convert::TryFrom for super::ImageResultsPage { type Error = String; - fn try_from(value: ImageResultsPage) -> Result { + fn try_from(value: ImageResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -5695,7 +6013,7 @@ pub mod types { impl std::convert::TryFrom for super::Instance { type Error = String; - fn try_from(value: Instance) -> Result { + fn try_from(value: Instance) -> Result { Ok(Self { description: value.description?, hostname: value.hostname?, @@ -5838,7 +6156,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceCreate { type Error = String; - fn try_from(value: InstanceCreate) -> Result { + fn try_from(value: InstanceCreate) -> Result { Ok(Self { description: value.description?, disks: value.disks?, @@ -5880,7 +6198,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceMigrate { type Error = String; - fn try_from(value: InstanceMigrate) -> Result { + fn try_from(value: InstanceMigrate) -> Result { Ok(Self { dst_sled_id: value.dst_sled_id?, }) @@ -5926,7 +6244,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceResultsPage { type Error = String; - fn try_from(value: InstanceResultsPage) -> Result { + fn try_from(value: InstanceResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -5976,7 +6294,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceSerialConsoleData { type Error = String; - fn try_from(value: InstanceSerialConsoleData) -> Result { + fn try_from(value: InstanceSerialConsoleData) -> Result { Ok(Self { data: value.data?, last_byte_offset: value.last_byte_offset?, @@ -6071,7 +6389,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPool { type Error = String; - fn try_from(value: IpPool) -> Result { + fn try_from(value: IpPool) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -6146,7 +6464,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPoolCreate { type Error = String; - fn try_from(value: IpPoolCreate) -> Result { + fn try_from(value: IpPoolCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -6207,7 +6525,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPoolRange { type Error = String; - fn try_from(value: IpPoolRange) -> Result { + fn try_from(value: IpPoolRange) -> Result { Ok(Self { id: value.id?, range: value.range?, @@ -6255,7 +6573,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPoolRangeResultsPage { type Error = String; - fn try_from(value: IpPoolRangeResultsPage) -> Result { + fn try_from(value: IpPoolRangeResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -6302,7 +6620,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPoolResultsPage { type Error = String; - fn try_from(value: IpPoolResultsPage) -> Result { + fn try_from(value: IpPoolResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -6349,7 +6667,7 @@ pub mod types { impl std::convert::TryFrom for super::IpPoolUpdate { type Error = String; - fn try_from(value: IpPoolUpdate) -> Result { + fn try_from(value: IpPoolUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -6396,7 +6714,7 @@ pub mod types { impl std::convert::TryFrom for super::Ipv4Range { type Error = String; - fn try_from(value: Ipv4Range) -> Result { + fn try_from(value: Ipv4Range) -> Result { Ok(Self { first: value.first?, last: value.last?, @@ -6443,7 +6761,7 @@ pub mod types { impl std::convert::TryFrom for super::Ipv6Range { type Error = String; - fn try_from(value: Ipv6Range) -> Result { + fn try_from(value: Ipv6Range) -> Result { Ok(Self { first: value.first?, last: value.last?, @@ -6490,7 +6808,7 @@ pub mod types { impl std::convert::TryFrom for super::Measurement { type Error = String; - fn try_from(value: Measurement) -> Result { + fn try_from(value: Measurement) -> Result { Ok(Self { datum: value.datum?, timestamp: value.timestamp?, @@ -6537,7 +6855,7 @@ pub mod types { impl std::convert::TryFrom for super::MeasurementResultsPage { type Error = String; - fn try_from(value: MeasurementResultsPage) -> Result { + fn try_from(value: MeasurementResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -6692,7 +7010,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterface { type Error = String; - fn try_from(value: NetworkInterface) -> Result { + fn try_from(value: NetworkInterface) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -6784,7 +7102,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterfaceCreate { type Error = String; - fn try_from(value: NetworkInterfaceCreate) -> Result { + fn try_from(value: NetworkInterfaceCreate) -> Result { Ok(Self { description: value.description?, ip: value.ip?, @@ -6834,7 +7152,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterfaceResultsPage { type Error = String; - fn try_from(value: NetworkInterfaceResultsPage) -> Result { + fn try_from(value: NetworkInterfaceResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -6893,7 +7211,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterfaceUpdate { type Error = String; - fn try_from(value: NetworkInterfaceUpdate) -> Result { + fn try_from(value: NetworkInterfaceUpdate) -> Result { Ok(Self { description: value.description?, make_primary: value.make_primary?, @@ -6977,7 +7295,7 @@ pub mod types { impl std::convert::TryFrom for super::Organization { type Error = String; - fn try_from(value: Organization) -> Result { + fn try_from(value: Organization) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -7027,7 +7345,7 @@ pub mod types { impl std::convert::TryFrom for super::OrganizationCreate { type Error = String; - fn try_from(value: OrganizationCreate) -> Result { + fn try_from(value: OrganizationCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -7074,7 +7392,7 @@ pub mod types { impl std::convert::TryFrom for super::OrganizationResultsPage { type Error = String; - fn try_from(value: OrganizationResultsPage) -> Result { + fn try_from(value: OrganizationResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -7112,7 +7430,7 @@ pub mod types { impl std::convert::TryFrom for super::OrganizationRolePolicy { type Error = String; - fn try_from(value: OrganizationRolePolicy) -> Result { + fn try_from(value: OrganizationRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -7172,7 +7490,7 @@ pub mod types { for super::OrganizationRoleRoleAssignment { type Error = String; - fn try_from(value: OrganizationRoleRoleAssignment) -> Result { + fn try_from(value: OrganizationRoleRoleAssignment) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -7220,7 +7538,7 @@ pub mod types { impl std::convert::TryFrom for super::OrganizationUpdate { type Error = String; - fn try_from(value: OrganizationUpdate) -> Result { + fn try_from(value: OrganizationUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -7315,7 +7633,7 @@ pub mod types { impl std::convert::TryFrom for super::Project { type Error = String; - fn try_from(value: Project) -> Result { + fn try_from(value: Project) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -7366,7 +7684,7 @@ pub mod types { impl std::convert::TryFrom for super::ProjectCreate { type Error = String; - fn try_from(value: ProjectCreate) -> Result { + fn try_from(value: ProjectCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -7413,7 +7731,7 @@ pub mod types { impl std::convert::TryFrom for super::ProjectResultsPage { type Error = String; - fn try_from(value: ProjectResultsPage) -> Result { + fn try_from(value: ProjectResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -7451,7 +7769,7 @@ pub mod types { impl std::convert::TryFrom for super::ProjectRolePolicy { type Error = String; - fn try_from(value: ProjectRolePolicy) -> Result { + fn try_from(value: ProjectRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -7509,7 +7827,7 @@ pub mod types { impl std::convert::TryFrom for super::ProjectRoleRoleAssignment { type Error = String; - fn try_from(value: ProjectRoleRoleAssignment) -> Result { + fn try_from(value: ProjectRoleRoleAssignment) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -7557,7 +7875,7 @@ pub mod types { impl std::convert::TryFrom for super::ProjectUpdate { type Error = String; - fn try_from(value: ProjectUpdate) -> Result { + fn try_from(value: ProjectUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -7616,7 +7934,7 @@ pub mod types { impl std::convert::TryFrom for super::Rack { type Error = String; - fn try_from(value: Rack) -> Result { + fn try_from(value: Rack) -> Result { Ok(Self { id: value.id?, time_created: value.time_created?, @@ -7664,7 +7982,7 @@ pub mod types { impl std::convert::TryFrom for super::RackResultsPage { type Error = String; - fn try_from(value: RackResultsPage) -> Result { + fn try_from(value: RackResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -7711,7 +8029,7 @@ pub mod types { impl std::convert::TryFrom for super::Role { type Error = String; - fn try_from(value: Role) -> Result { + fn try_from(value: Role) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -7758,7 +8076,7 @@ pub mod types { impl std::convert::TryFrom for super::RoleResultsPage { type Error = String; - fn try_from(value: RoleResultsPage) -> Result { + fn try_from(value: RoleResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -7889,7 +8207,7 @@ pub mod types { impl std::convert::TryFrom for super::RouterRoute { type Error = String; - fn try_from(value: RouterRoute) -> Result { + fn try_from(value: RouterRoute) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -7967,7 +8285,7 @@ pub mod types { impl std::convert::TryFrom for super::RouterRouteCreateParams { type Error = String; - fn try_from(value: RouterRouteCreateParams) -> Result { + fn try_from(value: RouterRouteCreateParams) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -8016,7 +8334,7 @@ pub mod types { impl std::convert::TryFrom for super::RouterRouteResultsPage { type Error = String; - fn try_from(value: RouterRouteResultsPage) -> Result { + fn try_from(value: RouterRouteResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -8087,7 +8405,7 @@ pub mod types { impl std::convert::TryFrom for super::RouterRouteUpdateParams { type Error = String; - fn try_from(value: RouterRouteUpdateParams) -> Result { + fn try_from(value: RouterRouteUpdateParams) -> Result { Ok(Self { description: value.description?, destination: value.destination?, @@ -8136,7 +8454,7 @@ pub mod types { impl std::convert::TryFrom for super::Saga { type Error = String; - fn try_from(value: Saga) -> Result { + fn try_from(value: Saga) -> Result { Ok(Self { id: value.id?, state: value.state?, @@ -8183,7 +8501,7 @@ pub mod types { impl std::convert::TryFrom for super::SagaResultsPage { type Error = String; - fn try_from(value: SagaResultsPage) -> Result { + fn try_from(value: SagaResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -8343,7 +8661,7 @@ pub mod types { impl std::convert::TryFrom for super::SamlIdentityProvider { type Error = String; - fn try_from(value: SamlIdentityProvider) -> Result { + fn try_from(value: SamlIdentityProvider) -> Result { Ok(Self { acs_url: value.acs_url?, description: value.description?, @@ -8493,7 +8811,7 @@ pub mod types { impl std::convert::TryFrom for super::SamlIdentityProviderCreate { type Error = String; - fn try_from(value: SamlIdentityProviderCreate) -> Result { + fn try_from(value: SamlIdentityProviderCreate) -> Result { Ok(Self { acs_url: value.acs_url?, description: value.description?, @@ -8612,7 +8930,7 @@ pub mod types { impl std::convert::TryFrom for super::Silo { type Error = String; - fn try_from(value: Silo) -> Result { + fn try_from(value: Silo) -> Result { Ok(Self { description: value.description?, discoverable: value.discoverable?, @@ -8693,7 +9011,7 @@ pub mod types { impl std::convert::TryFrom for super::SiloCreate { type Error = String; - fn try_from(value: SiloCreate) -> Result { + fn try_from(value: SiloCreate) -> Result { Ok(Self { description: value.description?, discoverable: value.discoverable?, @@ -8742,7 +9060,7 @@ pub mod types { impl std::convert::TryFrom for super::SiloResultsPage { type Error = String; - fn try_from(value: SiloResultsPage) -> Result { + fn try_from(value: SiloResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -8780,7 +9098,7 @@ pub mod types { impl std::convert::TryFrom for super::SiloRolePolicy { type Error = String; - fn try_from(value: SiloRolePolicy) -> Result { + fn try_from(value: SiloRolePolicy) -> Result { Ok(Self { role_assignments: value.role_assignments?, }) @@ -8838,7 +9156,7 @@ pub mod types { impl std::convert::TryFrom for super::SiloRoleRoleAssignment { type Error = String; - fn try_from(value: SiloRoleRoleAssignment) -> Result { + fn try_from(value: SiloRoleRoleAssignment) -> Result { Ok(Self { identity_id: value.identity_id?, identity_type: value.identity_type?, @@ -8910,7 +9228,7 @@ pub mod types { impl std::convert::TryFrom for super::Sled { type Error = String; - fn try_from(value: Sled) -> Result { + fn try_from(value: Sled) -> Result { Ok(Self { id: value.id?, service_address: value.service_address?, @@ -8959,7 +9277,7 @@ pub mod types { impl std::convert::TryFrom for super::SledResultsPage { type Error = String; - fn try_from(value: SledResultsPage) -> Result { + fn try_from(value: SledResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9078,7 +9396,7 @@ pub mod types { impl std::convert::TryFrom for super::Snapshot { type Error = String; - fn try_from(value: Snapshot) -> Result { + fn try_from(value: Snapshot) -> Result { Ok(Self { description: value.description?, disk_id: value.disk_id?, @@ -9143,7 +9461,7 @@ pub mod types { impl std::convert::TryFrom for super::SnapshotCreate { type Error = String; - fn try_from(value: SnapshotCreate) -> Result { + fn try_from(value: SnapshotCreate) -> Result { Ok(Self { description: value.description?, disk: value.disk?, @@ -9191,7 +9509,7 @@ pub mod types { impl std::convert::TryFrom for super::SnapshotResultsPage { type Error = String; - fn try_from(value: SnapshotResultsPage) -> Result { + fn try_from(value: SnapshotResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9226,7 +9544,7 @@ pub mod types { impl std::convert::TryFrom for super::SpoofLoginBody { type Error = String; - fn try_from(value: SpoofLoginBody) -> Result { + fn try_from(value: SpoofLoginBody) -> Result { Ok(Self { username: value.username?, }) @@ -9332,7 +9650,7 @@ pub mod types { impl std::convert::TryFrom for super::SshKey { type Error = String; - fn try_from(value: SshKey) -> Result { + fn try_from(value: SshKey) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -9396,7 +9714,7 @@ pub mod types { impl std::convert::TryFrom for super::SshKeyCreate { type Error = String; - fn try_from(value: SshKeyCreate) -> Result { + fn try_from(value: SshKeyCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -9444,7 +9762,7 @@ pub mod types { impl std::convert::TryFrom for super::SshKeyResultsPage { type Error = String; - fn try_from(value: SshKeyResultsPage) -> Result { + fn try_from(value: SshKeyResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9515,7 +9833,7 @@ pub mod types { impl std::convert::TryFrom for super::TimeseriesSchema { type Error = String; - fn try_from(value: TimeseriesSchema) -> Result { + fn try_from(value: TimeseriesSchema) -> Result { Ok(Self { created: value.created?, datum_type: value.datum_type?, @@ -9564,7 +9882,7 @@ pub mod types { impl std::convert::TryFrom for super::TimeseriesSchemaResultsPage { type Error = String; - fn try_from(value: TimeseriesSchemaResultsPage) -> Result { + fn try_from(value: TimeseriesSchemaResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9611,7 +9929,7 @@ pub mod types { impl std::convert::TryFrom for super::User { type Error = String; - fn try_from(value: User) -> Result { + fn try_from(value: User) -> Result { Ok(Self { display_name: value.display_name?, id: value.id?, @@ -9694,7 +10012,7 @@ pub mod types { impl std::convert::TryFrom for super::UserBuiltin { type Error = String; - fn try_from(value: UserBuiltin) -> Result { + fn try_from(value: UserBuiltin) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -9744,7 +10062,7 @@ pub mod types { impl std::convert::TryFrom for super::UserBuiltinResultsPage { type Error = String; - fn try_from(value: UserBuiltinResultsPage) -> Result { + fn try_from(value: UserBuiltinResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9791,7 +10109,7 @@ pub mod types { impl std::convert::TryFrom for super::UserResultsPage { type Error = String; - fn try_from(value: UserResultsPage) -> Result { + fn try_from(value: UserResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -9925,7 +10243,7 @@ pub mod types { impl std::convert::TryFrom for super::Vpc { type Error = String; - fn try_from(value: Vpc) -> Result { + fn try_from(value: Vpc) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, @@ -10003,7 +10321,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcCreate { type Error = String; - fn try_from(value: VpcCreate) -> Result { + fn try_from(value: VpcCreate) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, @@ -10172,7 +10490,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcFirewallRule { type Error = String; - fn try_from(value: VpcFirewallRule) -> Result { + fn try_from(value: VpcFirewallRule) -> Result { Ok(Self { action: value.action?, description: value.description?, @@ -10241,7 +10559,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcFirewallRuleFilter { type Error = String; - fn try_from(value: VpcFirewallRuleFilter) -> Result { + fn try_from(value: VpcFirewallRuleFilter) -> Result { Ok(Self { hosts: value.hosts?, ports: value.ports?, @@ -10361,7 +10679,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcFirewallRuleUpdate { type Error = String; - fn try_from(value: VpcFirewallRuleUpdate) -> Result { + fn try_from(value: VpcFirewallRuleUpdate) -> Result { Ok(Self { action: value.action?, description: value.description?, @@ -10402,7 +10720,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcFirewallRuleUpdateParams { type Error = String; - fn try_from(value: VpcFirewallRuleUpdateParams) -> Result { + fn try_from(value: VpcFirewallRuleUpdateParams) -> Result { Ok(Self { rules: value.rules?, }) @@ -10436,7 +10754,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcFirewallRules { type Error = String; - fn try_from(value: VpcFirewallRules) -> Result { + fn try_from(value: VpcFirewallRules) -> Result { Ok(Self { rules: value.rules?, }) @@ -10482,7 +10800,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcResultsPage { type Error = String; - fn try_from(value: VpcResultsPage) -> Result { + fn try_from(value: VpcResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -10589,7 +10907,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcRouter { type Error = String; - fn try_from(value: VpcRouter) -> Result { + fn try_from(value: VpcRouter) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -10641,7 +10959,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcRouterCreate { type Error = String; - fn try_from(value: VpcRouterCreate) -> Result { + fn try_from(value: VpcRouterCreate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -10688,7 +11006,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcRouterResultsPage { type Error = String; - fn try_from(value: VpcRouterResultsPage) -> Result { + fn try_from(value: VpcRouterResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -10735,7 +11053,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcRouterUpdate { type Error = String; - fn try_from(value: VpcRouterUpdate) -> Result { + fn try_from(value: VpcRouterUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -10854,7 +11172,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcSubnet { type Error = String; - fn try_from(value: VpcSubnet) -> Result { + fn try_from(value: VpcSubnet) -> Result { Ok(Self { description: value.description?, id: value.id?, @@ -10931,7 +11249,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcSubnetCreate { type Error = String; - fn try_from(value: VpcSubnetCreate) -> Result { + fn try_from(value: VpcSubnetCreate) -> Result { Ok(Self { description: value.description?, ipv4_block: value.ipv4_block?, @@ -10980,7 +11298,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcSubnetResultsPage { type Error = String; - fn try_from(value: VpcSubnetResultsPage) -> Result { + fn try_from(value: VpcSubnetResultsPage) -> Result { Ok(Self { items: value.items?, next_page: value.next_page?, @@ -11027,7 +11345,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcSubnetUpdate { type Error = String; - fn try_from(value: VpcSubnetUpdate) -> Result { + fn try_from(value: VpcSubnetUpdate) -> Result { Ok(Self { description: value.description?, name: value.name?, @@ -11086,7 +11404,7 @@ pub mod types { impl std::convert::TryFrom for super::VpcUpdate { type Error = String; - fn try_from(value: VpcUpdate) -> Result { + fn try_from(value: VpcUpdate) -> Result { Ok(Self { description: value.description?, dns_name: value.dns_name?, diff --git a/progenitor-impl/tests/output/nexus-positional.out b/progenitor-impl/tests/output/nexus-positional.out index b5c1780..c8b9312 100644 --- a/progenitor-impl/tests/output/nexus-positional.out +++ b/progenitor-impl/tests/output/nexus-positional.out @@ -69,14 +69,14 @@ pub mod types { pub struct BlockSize(i64); impl std::ops::Deref for BlockSize { type Target = i64; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &i64 { &self.0 } } impl std::convert::TryFrom for BlockSize { type Error = &'static str; - fn try_from(value: i64) -> Result { + fn try_from(value: i64) -> Result { if ![512_i64, 2048_i64, 4096_i64].contains(&value) { Err("invalid value") } else { @@ -96,7 +96,7 @@ pub mod types { pub struct ByteCount(pub u64); impl std::ops::Deref for ByteCount { type Target = u64; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &u64 { &self.0 } } @@ -180,7 +180,7 @@ pub mod types { impl std::str::FromStr for DatumType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "bool" => Ok(Self::Bool), "i64" => Ok(Self::I64), @@ -196,6 +196,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for DatumType { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct DerEncodedKeyPair { ///request signing private key (base64 encoded der file) @@ -302,7 +316,7 @@ pub mod types { impl std::str::FromStr for DiskMetricName { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "activated" => Ok(Self::Activated), "flush" => Ok(Self::Flush), @@ -315,6 +329,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for DiskMetricName { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct DiskResultsPage { @@ -446,7 +474,7 @@ pub mod types { impl std::str::FromStr for FieldSource { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "target" => Ok(Self::Target), "metric" => Ok(Self::Metric), @@ -455,6 +483,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for FieldSource { + type Error = &'static str; + 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 { + value.parse() + } + } + ///The `FieldType` identifies the data type of a target or metric field. #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum FieldType { @@ -484,7 +526,7 @@ pub mod types { impl std::str::FromStr for FieldType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "string" => Ok(Self::String), "i64" => Ok(Self::I64), @@ -496,6 +538,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for FieldType { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum FleetRole { #[serde(rename = "admin")] @@ -518,7 +574,7 @@ pub mod types { impl std::str::FromStr for FleetRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -528,6 +584,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for FleetRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -723,7 +793,7 @@ pub mod types { impl std::str::FromStr for IdSortMode { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "id_ascending" => Ok(Self::IdAscending), _ => Err("invalid value"), @@ -731,6 +801,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IdSortMode { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of an [`IdentityProvider`] #[derive(Clone, Debug, Deserialize, Serialize)] pub struct IdentityProvider { @@ -774,7 +858,7 @@ pub mod types { impl std::str::FromStr for IdentityProviderType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "saml" => Ok(Self::Saml), _ => Err("invalid value"), @@ -782,6 +866,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IdentityProviderType { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Describes what kind of identity is described by an id #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum IdentityType { @@ -799,7 +897,7 @@ pub mod types { impl std::str::FromStr for IdentityType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "silo_user" => Ok(Self::SiloUser), _ => Err("invalid value"), @@ -807,6 +905,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IdentityType { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "type")] pub enum IdpMetadataSource { @@ -910,7 +1022,7 @@ pub mod types { pub struct InstanceCpuCount(pub u16); impl std::ops::Deref for InstanceCpuCount { type Target = u16; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &u16 { &self.0 } } @@ -1060,7 +1172,7 @@ pub mod types { impl std::str::FromStr for InstanceState { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "creating" => Ok(Self::Creating), "starting" => Ok(Self::Starting), @@ -1077,6 +1189,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for InstanceState { + type Error = &'static str; + 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 { + value.parse() + } + } + ///The kind of an external IP address for an instance #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum IpKind { @@ -1097,7 +1223,7 @@ pub mod types { impl std::str::FromStr for IpKind { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "ephemeral" => Ok(Self::Ephemeral), "floating" => Ok(Self::Floating), @@ -1106,6 +1232,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for IpKind { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(untagged)] pub enum IpNet { @@ -1113,27 +1253,30 @@ pub mod types { V6(Ipv6Net), } + impl std::str::FromStr for IpNet { + type Err = &'static str; + 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") + } + } + } + impl std::convert::TryFrom<&str> for IpNet { type Error = &'static str; - fn try_from(value: &str) -> Result { - Err("") - .or_else(|_: Self::Error| Ok(Self::V4(Ipv4Net::try_from(value)?))) - .or_else(|_: Self::Error| Ok(Self::V6(Ipv6Net::try_from(value)?))) - .map_err(|_: Self::Error| "string conversion failed for all variants") + 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 { - Self::try_from(value.as_str()) - } - } - - impl std::convert::TryFrom for IpNet { - type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1225,30 +1368,30 @@ pub mod types { pub struct Ipv4Net(String); impl std::ops::Deref for Ipv4Net { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for Ipv4Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for Ipv4Net { + type Err = &'static str; + fn from_str(value: &str) -> Result { if regress :: Regex :: new ("^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([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])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$") . unwrap () . find (value) . is_none () { return Err ("doesn't match pattern \"^(10\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([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])|172\\.(1[6-9]|2[0-9]|3[0-1])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[2-9]|2[0-9]|3[0-2])|192\\.168\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\/(1[6-9]|2[0-9]|3[0-2]))$\"") ; } Ok(Self(value.to_string())) } } - impl std::convert::TryFrom<&String> for Ipv4Net { + impl std::convert::TryFrom<&str> for Ipv4Net { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for Ipv4Net { + impl std::convert::TryFrom<&String> for Ipv4Net { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1257,8 +1400,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1276,30 +1420,30 @@ pub mod types { pub struct Ipv6Net(String); impl std::ops::Deref for Ipv6Net { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for Ipv6Net { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for Ipv6Net { + type Err = &'static str; + 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])$") . unwrap () . find (value) . is_none () { 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])$\"") ; } Ok(Self(value.to_string())) } } - impl std::convert::TryFrom<&String> for Ipv6Net { + impl std::convert::TryFrom<&str> for Ipv6Net { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for Ipv6Net { + impl std::convert::TryFrom<&String> for Ipv6Net { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1308,8 +1452,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1328,14 +1473,14 @@ pub mod types { pub struct L4PortRange(String); impl std::ops::Deref for L4PortRange { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for L4PortRange { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for L4PortRange { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 11usize { return Err("longer than 11 characters"); } @@ -1353,17 +1498,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for L4PortRange { + impl std::convert::TryFrom<&str> for L4PortRange { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for L4PortRange { + impl std::convert::TryFrom<&String> for L4PortRange { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1372,8 +1517,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1382,14 +1528,14 @@ pub mod types { pub struct MacAddr(String); impl std::ops::Deref for MacAddr { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for MacAddr { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for MacAddr { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 17usize { return Err("longer than 17 characters"); } @@ -1407,17 +1553,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for MacAddr { + impl std::convert::TryFrom<&str> for MacAddr { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for MacAddr { + impl std::convert::TryFrom<&String> for MacAddr { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1426,8 +1572,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1455,14 +1602,14 @@ pub mod types { pub struct Name(String); impl std::ops::Deref for Name { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for Name { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for Name { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 63usize { return Err("longer than 63 characters"); } @@ -1471,17 +1618,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for Name { + impl std::convert::TryFrom<&str> for Name { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for Name { + impl std::convert::TryFrom<&String> for Name { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1490,8 +1637,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -1518,7 +1666,7 @@ pub mod types { impl std::str::FromStr for NameOrIdSortMode { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), "name_descending" => Ok(Self::NameDescending), @@ -1528,6 +1676,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for NameOrIdSortMode { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Supported set of sort modes for scanning by name only /// ///Currently, we only support scanning in ascending order. @@ -1547,7 +1709,7 @@ pub mod types { impl std::str::FromStr for NameSortMode { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "name_ascending" => Ok(Self::NameAscending), _ => Err("invalid value"), @@ -1555,6 +1717,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for NameSortMode { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A `NetworkInterface` represents a virtual network interface device. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct NetworkInterface { @@ -1690,7 +1866,7 @@ pub mod types { impl std::str::FromStr for OrganizationRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -1700,6 +1876,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for OrganizationRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -1791,7 +1981,7 @@ pub mod types { impl std::str::FromStr for ProjectRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -1801,6 +1991,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for ProjectRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -1869,14 +2073,14 @@ pub mod types { pub struct RoleName(String); impl std::ops::Deref for RoleName { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for RoleName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for RoleName { + type Err = &'static str; + fn from_str(value: &str) -> Result { if value.len() > 63usize { return Err("longer than 63 characters"); } @@ -1891,17 +2095,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for RoleName { + impl std::convert::TryFrom<&str> for RoleName { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for RoleName { + impl std::convert::TryFrom<&String> for RoleName { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -1910,8 +2114,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -2031,7 +2236,7 @@ pub mod types { impl std::str::FromStr for RouterRouteKind { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "default" => Ok(Self::Default), "vpc_subnet" => Ok(Self::VpcSubnet), @@ -2042,6 +2247,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for RouterRouteKind { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct RouterRouteResultsPage { @@ -2221,7 +2440,7 @@ pub mod types { impl std::str::FromStr for SiloRole { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "admin" => Ok(Self::Admin), "collaborator" => Ok(Self::Collaborator), @@ -2231,6 +2450,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for SiloRole { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Client view of a [`Policy`], which describes how this resource may be /// accessed /// @@ -2367,14 +2600,14 @@ pub mod types { pub struct TimeseriesName(String); impl std::ops::Deref for TimeseriesName { type Target = String; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &String { &self.0 } } - impl std::convert::TryFrom<&str> for TimeseriesName { - type Error = &'static str; - fn try_from(value: &str) -> Result { + impl std::str::FromStr for TimeseriesName { + type Err = &'static str; + 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]+))*)", ) @@ -2388,17 +2621,17 @@ pub mod types { } } - impl std::convert::TryFrom<&String> for TimeseriesName { + impl std::convert::TryFrom<&str> for TimeseriesName { type Error = &'static str; - fn try_from(value: &String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &str) -> Result { + value.parse() } } - impl std::convert::TryFrom for TimeseriesName { + impl std::convert::TryFrom<&String> for TimeseriesName { type Error = &'static str; - fn try_from(value: String) -> Result { - Self::try_from(value.as_str()) + fn try_from(value: &String) -> Result { + value.parse() } } @@ -2407,8 +2640,9 @@ pub mod types { where D: serde::Deserializer<'de>, { - Self::try_from(String::deserialize(deserializer)?) - .map_err(|e| ::custom(e.to_string())) + String::deserialize(deserializer)? + .parse() + .map_err(|e: &'static str| ::custom(e.to_string())) } } @@ -2487,7 +2721,7 @@ pub mod types { impl std::str::FromStr for UserProvisionType { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "fixed" => Ok(Self::Fixed), "jit" => Ok(Self::Jit), @@ -2496,6 +2730,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for UserProvisionType { + type Error = &'static str; + fn try_from(value: &str) -> Result { + value.parse() + } + } + + impl std::convert::TryFrom<&String> for UserProvisionType { + type Error = &'static str; + fn try_from(value: &String) -> Result { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct UserResultsPage { @@ -2593,7 +2841,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleAction { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "allow" => Ok(Self::Allow), "deny" => Ok(Self::Deny), @@ -2602,6 +2850,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleAction { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum VpcFirewallRuleDirection { #[serde(rename = "inbound")] @@ -2621,7 +2883,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleDirection { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "inbound" => Ok(Self::Inbound), "outbound" => Ok(Self::Outbound), @@ -2630,6 +2892,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleDirection { + type Error = &'static str; + 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 { + value.parse() + } + } + ///Filter for a firewall rule. A given packet must match every field that /// is present for the rule to apply to it. A packet matches a field if any /// entry in that field matches the packet. @@ -2692,7 +2968,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleProtocol { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "TCP" => Ok(Self::Tcp), "UDP" => Ok(Self::Udp), @@ -2702,6 +2978,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleProtocol { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum VpcFirewallRuleStatus { #[serde(rename = "disabled")] @@ -2721,7 +3011,7 @@ pub mod types { impl std::str::FromStr for VpcFirewallRuleStatus { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "disabled" => Ok(Self::Disabled), "enabled" => Ok(Self::Enabled), @@ -2730,6 +3020,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcFirewallRuleStatus { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to /// which a firewall rule applies. #[derive(Clone, Debug, Deserialize, Serialize)] @@ -2843,7 +3147,7 @@ pub mod types { impl std::str::FromStr for VpcRouterKind { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "system" => Ok(Self::System), "custom" => Ok(Self::Custom), @@ -2852,6 +3156,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for VpcRouterKind { + type Error = &'static str; + 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 { + value.parse() + } + } + ///A single page of results #[derive(Clone, Debug, Deserialize, Serialize)] pub struct VpcRouterResultsPage { diff --git a/progenitor-impl/tests/output/propolis-server-builder-tagged.out b/progenitor-impl/tests/output/propolis-server-builder-tagged.out index a45ff73..28a7c37 100644 --- a/progenitor-impl/tests/output/propolis-server-builder-tagged.out +++ b/progenitor-impl/tests/output/propolis-server-builder-tagged.out @@ -245,7 +245,7 @@ pub mod types { impl std::str::FromStr for InstanceState { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "Creating" => Ok(Self::Creating), "Starting" => Ok(Self::Starting), @@ -262,6 +262,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for InstanceState { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct InstanceStateMonitorRequest { pub gen: u64, @@ -306,7 +320,7 @@ pub mod types { impl std::str::FromStr for InstanceStateRequested { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "Run" => Ok(Self::Run), "Stop" => Ok(Self::Stop), @@ -317,6 +331,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for InstanceStateRequested { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum MigrationState { Sync, @@ -350,7 +378,7 @@ pub mod types { impl std::str::FromStr for MigrationState { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "Sync" => Ok(Self::Sync), "RamPush" => Ok(Self::RamPush), @@ -367,6 +395,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for MigrationState { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct NetworkInterface { pub attachment: NetworkInterfaceAttachmentState, @@ -404,7 +446,7 @@ pub mod types { pub struct Slot(pub u8); impl std::ops::Deref for Slot { type Target = u8; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &u8 { &self.0 } } @@ -576,7 +618,7 @@ pub mod types { impl std::convert::TryFrom for super::CrucibleOpts { type Error = String; - fn try_from(value: CrucibleOpts) -> Result { + fn try_from(value: CrucibleOpts) -> Result { Ok(Self { cert_pem: value.cert_pem?, control: value.control?, @@ -643,7 +685,7 @@ pub mod types { impl std::convert::TryFrom for super::DiskAttachment { type Error = String; - fn try_from(value: DiskAttachment) -> Result { + fn try_from(value: DiskAttachment) -> Result { Ok(Self { disk_id: value.disk_id?, generation_id: value.generation_id?, @@ -744,7 +786,7 @@ pub mod types { impl std::convert::TryFrom for super::DiskRequest { type Error = String; - fn try_from(value: DiskRequest) -> Result { + fn try_from(value: DiskRequest) -> Result { Ok(Self { device: value.device?, gen: value.gen?, @@ -807,7 +849,7 @@ pub mod types { impl std::convert::TryFrom for super::Error { type Error = String; - fn try_from(value: Error) -> Result { + fn try_from(value: Error) -> Result { Ok(Self { error_code: value.error_code?, message: value.message?, @@ -879,7 +921,7 @@ pub mod types { impl std::convert::TryFrom for super::Instance { type Error = String; - fn try_from(value: Instance) -> Result { + fn try_from(value: Instance) -> Result { Ok(Self { disks: value.disks?, nics: value.nics?, @@ -967,7 +1009,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceEnsureRequest { type Error = String; - fn try_from(value: InstanceEnsureRequest) -> Result { + fn try_from(value: InstanceEnsureRequest) -> Result { Ok(Self { cloud_init_bytes: value.cloud_init_bytes?, disks: value.disks?, @@ -1005,7 +1047,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceEnsureResponse { type Error = String; - fn try_from(value: InstanceEnsureResponse) -> Result { + fn try_from(value: InstanceEnsureResponse) -> Result { Ok(Self { migrate: value.migrate?, }) @@ -1039,7 +1081,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceGetResponse { type Error = String; - fn try_from(value: InstanceGetResponse) -> Result { + fn try_from(value: InstanceGetResponse) -> Result { Ok(Self { instance: value.instance?, }) @@ -1099,7 +1141,7 @@ pub mod types { for super::InstanceMigrateInitiateRequest { type Error = String; - fn try_from(value: InstanceMigrateInitiateRequest) -> Result { + fn try_from(value: InstanceMigrateInitiateRequest) -> Result { Ok(Self { migration_id: value.migration_id?, src_addr: value.src_addr?, @@ -1137,7 +1179,7 @@ pub mod types { for super::InstanceMigrateInitiateResponse { type Error = String; - fn try_from(value: InstanceMigrateInitiateResponse) -> Result { + fn try_from(value: InstanceMigrateInitiateResponse) -> Result { Ok(Self { migration_id: value.migration_id?, }) @@ -1171,7 +1213,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceMigrateStatusRequest { type Error = String; - fn try_from(value: InstanceMigrateStatusRequest) -> Result { + fn try_from(value: InstanceMigrateStatusRequest) -> Result { Ok(Self { migration_id: value.migration_id?, }) @@ -1205,7 +1247,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceMigrateStatusResponse { type Error = String; - fn try_from(value: InstanceMigrateStatusResponse) -> Result { + fn try_from(value: InstanceMigrateStatusResponse) -> Result { Ok(Self { state: value.state?, }) @@ -1311,7 +1353,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceProperties { type Error = String; - fn try_from(value: InstanceProperties) -> Result { + fn try_from(value: InstanceProperties) -> Result { Ok(Self { bootrom_id: value.bootrom_id?, description: value.description?, @@ -1351,7 +1393,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceStateMonitorRequest { type Error = String; - fn try_from(value: InstanceStateMonitorRequest) -> Result { + fn try_from(value: InstanceStateMonitorRequest) -> Result { Ok(Self { gen: value.gen? }) } } @@ -1395,7 +1437,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceStateMonitorResponse { type Error = String; - fn try_from(value: InstanceStateMonitorResponse) -> Result { + fn try_from(value: InstanceStateMonitorResponse) -> Result { Ok(Self { gen: value.gen?, state: value.state?, @@ -1442,7 +1484,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterface { type Error = String; - fn try_from(value: NetworkInterface) -> Result { + fn try_from(value: NetworkInterface) -> Result { Ok(Self { attachment: value.attachment?, name: value.name?, @@ -1489,7 +1531,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterfaceRequest { type Error = String; - fn try_from(value: NetworkInterfaceRequest) -> Result { + fn try_from(value: NetworkInterfaceRequest) -> Result { Ok(Self { name: value.name?, slot: value.slot?, diff --git a/progenitor-impl/tests/output/propolis-server-builder.out b/progenitor-impl/tests/output/propolis-server-builder.out index 8aa9dbc..63937ae 100644 --- a/progenitor-impl/tests/output/propolis-server-builder.out +++ b/progenitor-impl/tests/output/propolis-server-builder.out @@ -247,7 +247,7 @@ pub mod types { impl std::str::FromStr for InstanceState { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "Creating" => Ok(Self::Creating), "Starting" => Ok(Self::Starting), @@ -264,6 +264,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for InstanceState { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct InstanceStateMonitorRequest { pub gen: u64, @@ -310,7 +324,7 @@ pub mod types { impl std::str::FromStr for InstanceStateRequested { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "Run" => Ok(Self::Run), "Stop" => Ok(Self::Stop), @@ -321,6 +335,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for InstanceStateRequested { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive( Clone, Copy, Debug, Deserialize, Eq, Hash, JsonSchema, Ord, PartialEq, PartialOrd, Serialize, )] @@ -356,7 +384,7 @@ pub mod types { impl std::str::FromStr for MigrationState { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "Sync" => Ok(Self::Sync), "RamPush" => Ok(Self::RamPush), @@ -373,6 +401,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for MigrationState { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, JsonSchema, Serialize)] pub struct NetworkInterface { pub attachment: NetworkInterfaceAttachmentState, @@ -410,7 +452,7 @@ pub mod types { pub struct Slot(pub u8); impl std::ops::Deref for Slot { type Target = u8; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &u8 { &self.0 } } @@ -582,7 +624,7 @@ pub mod types { impl std::convert::TryFrom for super::CrucibleOpts { type Error = String; - fn try_from(value: CrucibleOpts) -> Result { + fn try_from(value: CrucibleOpts) -> Result { Ok(Self { cert_pem: value.cert_pem?, control: value.control?, @@ -649,7 +691,7 @@ pub mod types { impl std::convert::TryFrom for super::DiskAttachment { type Error = String; - fn try_from(value: DiskAttachment) -> Result { + fn try_from(value: DiskAttachment) -> Result { Ok(Self { disk_id: value.disk_id?, generation_id: value.generation_id?, @@ -750,7 +792,7 @@ pub mod types { impl std::convert::TryFrom for super::DiskRequest { type Error = String; - fn try_from(value: DiskRequest) -> Result { + fn try_from(value: DiskRequest) -> Result { Ok(Self { device: value.device?, gen: value.gen?, @@ -813,7 +855,7 @@ pub mod types { impl std::convert::TryFrom for super::Error { type Error = String; - fn try_from(value: Error) -> Result { + fn try_from(value: Error) -> Result { Ok(Self { error_code: value.error_code?, message: value.message?, @@ -885,7 +927,7 @@ pub mod types { impl std::convert::TryFrom for super::Instance { type Error = String; - fn try_from(value: Instance) -> Result { + fn try_from(value: Instance) -> Result { Ok(Self { disks: value.disks?, nics: value.nics?, @@ -973,7 +1015,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceEnsureRequest { type Error = String; - fn try_from(value: InstanceEnsureRequest) -> Result { + fn try_from(value: InstanceEnsureRequest) -> Result { Ok(Self { cloud_init_bytes: value.cloud_init_bytes?, disks: value.disks?, @@ -1011,7 +1053,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceEnsureResponse { type Error = String; - fn try_from(value: InstanceEnsureResponse) -> Result { + fn try_from(value: InstanceEnsureResponse) -> Result { Ok(Self { migrate: value.migrate?, }) @@ -1045,7 +1087,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceGetResponse { type Error = String; - fn try_from(value: InstanceGetResponse) -> Result { + fn try_from(value: InstanceGetResponse) -> Result { Ok(Self { instance: value.instance?, }) @@ -1105,7 +1147,7 @@ pub mod types { for super::InstanceMigrateInitiateRequest { type Error = String; - fn try_from(value: InstanceMigrateInitiateRequest) -> Result { + fn try_from(value: InstanceMigrateInitiateRequest) -> Result { Ok(Self { migration_id: value.migration_id?, src_addr: value.src_addr?, @@ -1143,7 +1185,7 @@ pub mod types { for super::InstanceMigrateInitiateResponse { type Error = String; - fn try_from(value: InstanceMigrateInitiateResponse) -> Result { + fn try_from(value: InstanceMigrateInitiateResponse) -> Result { Ok(Self { migration_id: value.migration_id?, }) @@ -1177,7 +1219,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceMigrateStatusRequest { type Error = String; - fn try_from(value: InstanceMigrateStatusRequest) -> Result { + fn try_from(value: InstanceMigrateStatusRequest) -> Result { Ok(Self { migration_id: value.migration_id?, }) @@ -1211,7 +1253,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceMigrateStatusResponse { type Error = String; - fn try_from(value: InstanceMigrateStatusResponse) -> Result { + fn try_from(value: InstanceMigrateStatusResponse) -> Result { Ok(Self { state: value.state?, }) @@ -1317,7 +1359,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceProperties { type Error = String; - fn try_from(value: InstanceProperties) -> Result { + fn try_from(value: InstanceProperties) -> Result { Ok(Self { bootrom_id: value.bootrom_id?, description: value.description?, @@ -1357,7 +1399,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceStateMonitorRequest { type Error = String; - fn try_from(value: InstanceStateMonitorRequest) -> Result { + fn try_from(value: InstanceStateMonitorRequest) -> Result { Ok(Self { gen: value.gen? }) } } @@ -1401,7 +1443,7 @@ pub mod types { impl std::convert::TryFrom for super::InstanceStateMonitorResponse { type Error = String; - fn try_from(value: InstanceStateMonitorResponse) -> Result { + fn try_from(value: InstanceStateMonitorResponse) -> Result { Ok(Self { gen: value.gen?, state: value.state?, @@ -1448,7 +1490,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterface { type Error = String; - fn try_from(value: NetworkInterface) -> Result { + fn try_from(value: NetworkInterface) -> Result { Ok(Self { attachment: value.attachment?, name: value.name?, @@ -1495,7 +1537,7 @@ pub mod types { impl std::convert::TryFrom for super::NetworkInterfaceRequest { type Error = String; - fn try_from(value: NetworkInterfaceRequest) -> Result { + fn try_from(value: NetworkInterfaceRequest) -> Result { Ok(Self { name: value.name?, slot: value.slot?, diff --git a/progenitor-impl/tests/output/propolis-server-positional.out b/progenitor-impl/tests/output/propolis-server-positional.out index 7d42743..d8b2b0e 100644 --- a/progenitor-impl/tests/output/propolis-server-positional.out +++ b/progenitor-impl/tests/output/propolis-server-positional.out @@ -167,7 +167,7 @@ pub mod types { impl std::str::FromStr for InstanceState { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "Creating" => Ok(Self::Creating), "Starting" => Ok(Self::Starting), @@ -184,6 +184,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for InstanceState { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct InstanceStateMonitorRequest { pub gen: u64, @@ -216,7 +230,7 @@ pub mod types { impl std::str::FromStr for InstanceStateRequested { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "Run" => Ok(Self::Run), "Stop" => Ok(Self::Stop), @@ -227,6 +241,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for InstanceStateRequested { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum MigrationState { Sync, @@ -260,7 +288,7 @@ pub mod types { impl std::str::FromStr for MigrationState { type Err = &'static str; - fn from_str(value: &str) -> Result { + fn from_str(value: &str) -> Result { match value { "Sync" => Ok(Self::Sync), "RamPush" => Ok(Self::RamPush), @@ -277,6 +305,20 @@ pub mod types { } } + impl std::convert::TryFrom<&str> for MigrationState { + type Error = &'static str; + 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 { + value.parse() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct NetworkInterface { pub attachment: NetworkInterfaceAttachmentState, @@ -302,7 +344,7 @@ pub mod types { pub struct Slot(pub u8); impl std::ops::Deref for Slot { type Target = u8; - fn deref(&self) -> &Self::Target { + fn deref(&self) -> &u8 { &self.0 } } diff --git a/progenitor-impl/tests/output/test_default_params_builder.out b/progenitor-impl/tests/output/test_default_params_builder.out index d1c2752..f49160d 100644 --- a/progenitor-impl/tests/output/test_default_params_builder.out +++ b/progenitor-impl/tests/output/test_default_params_builder.out @@ -103,7 +103,7 @@ pub mod types { impl std::convert::TryFrom for super::BodyWithDefaults { type Error = String; - fn try_from(value: BodyWithDefaults) -> Result { + fn try_from(value: BodyWithDefaults) -> Result { Ok(Self { forty_two: value.forty_two?, s: value.s?, @@ -164,7 +164,7 @@ pub mod types { impl std::convert::TryFrom for super::Error { type Error = String; - fn try_from(value: Error) -> Result { + fn try_from(value: Error) -> Result { Ok(Self { error_code: value.error_code?, message: value.message?,