From c025d1742482d701946c292dcf104421d3cade8e Mon Sep 17 00:00:00 2001 From: kjuulh Date: Mon, 13 Mar 2023 20:33:24 +0100 Subject: [PATCH] fix: add support for String as well --- .../src/rust/templates/scalar_tmpl.rs | 6 +++ .../examples/{issues => }/iss-30-alt/main.rs | 2 +- .../examples/{issues => }/iss-30/main.rs | 0 crates/dagger-sdk/src/gen.rs | 42 +++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) rename crates/dagger-sdk/examples/{issues => }/iss-30-alt/main.rs (94%) rename crates/dagger-sdk/examples/{issues => }/iss-30/main.rs (100%) diff --git a/crates/dagger-codegen/src/rust/templates/scalar_tmpl.rs b/crates/dagger-codegen/src/rust/templates/scalar_tmpl.rs index f2380d4..069f2c3 100644 --- a/crates/dagger-codegen/src/rust/templates/scalar_tmpl.rs +++ b/crates/dagger-codegen/src/rust/templates/scalar_tmpl.rs @@ -18,5 +18,11 @@ pub fn render_scalar(t: &FullType) -> eyre::Result { $(t.name.pipe(|n| format_name(n)))(self.to_string()) } } + + impl Into<$(t.name.pipe(|n| format_name(n)))> for String { + fn into(self) -> $(t.name.pipe(|n| format_name(n))) { + $(t.name.pipe(|n| format_name(n)))(self.clone()) + } + } }) } diff --git a/crates/dagger-sdk/examples/issues/iss-30-alt/main.rs b/crates/dagger-sdk/examples/iss-30-alt/main.rs similarity index 94% rename from crates/dagger-sdk/examples/issues/iss-30-alt/main.rs rename to crates/dagger-sdk/examples/iss-30-alt/main.rs index 2c2a013..b523bf7 100644 --- a/crates/dagger-sdk/examples/issues/iss-30-alt/main.rs +++ b/crates/dagger-sdk/examples/iss-30-alt/main.rs @@ -22,7 +22,7 @@ async fn main() -> eyre::Result<()> { let ref_ = client .container_opts(QueryContainerOpts { id: None, - platform: Some(platform.into()), + platform: Some(platform.to_string().into()), }) .build_opts( context.id().await?, diff --git a/crates/dagger-sdk/examples/issues/iss-30/main.rs b/crates/dagger-sdk/examples/iss-30/main.rs similarity index 100% rename from crates/dagger-sdk/examples/issues/iss-30/main.rs rename to crates/dagger-sdk/examples/iss-30/main.rs diff --git a/crates/dagger-sdk/src/gen.rs b/crates/dagger-sdk/src/gen.rs index edb9b03..d146e17 100644 --- a/crates/dagger-sdk/src/gen.rs +++ b/crates/dagger-sdk/src/gen.rs @@ -14,6 +14,12 @@ impl Into for &str { CacheId(self.to_string()) } } + +impl Into for String { + fn into(self) -> CacheId { + CacheId(self.clone()) + } +} #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] pub struct ContainerId(pub String); @@ -22,6 +28,12 @@ impl Into for &str { ContainerId(self.to_string()) } } + +impl Into for String { + fn into(self) -> ContainerId { + ContainerId(self.clone()) + } +} #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] pub struct DirectoryId(pub String); @@ -30,6 +42,12 @@ impl Into for &str { DirectoryId(self.to_string()) } } + +impl Into for String { + fn into(self) -> DirectoryId { + DirectoryId(self.clone()) + } +} #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] pub struct FileId(pub String); @@ -38,6 +56,12 @@ impl Into for &str { FileId(self.to_string()) } } + +impl Into for String { + fn into(self) -> FileId { + FileId(self.clone()) + } +} #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] pub struct Platform(pub String); @@ -46,6 +70,12 @@ impl Into for &str { Platform(self.to_string()) } } + +impl Into for String { + fn into(self) -> Platform { + Platform(self.clone()) + } +} #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] pub struct SecretId(pub String); @@ -54,6 +84,12 @@ impl Into for &str { SecretId(self.to_string()) } } + +impl Into for String { + fn into(self) -> SecretId { + SecretId(self.clone()) + } +} #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] pub struct SocketId(pub String); @@ -62,6 +98,12 @@ impl Into for &str { SocketId(self.to_string()) } } + +impl Into for String { + fn into(self) -> SocketId { + SocketId(self.clone()) + } +} #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct BuildArg { pub name: String,