fix: add support for String as well

This commit is contained in:
Kasper Juul Hermansen 2023-03-13 20:33:24 +01:00
parent e3579a35e0
commit 471caf276b
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912
4 changed files with 49 additions and 1 deletions

View File

@ -18,5 +18,11 @@ pub fn render_scalar(t: &FullType) -> eyre::Result<rust::Tokens> {
$(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())
}
}
})
}

View File

@ -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?,

View File

@ -14,6 +14,12 @@ impl Into<CacheId> for &str {
CacheId(self.to_string())
}
}
impl Into<CacheId> 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<ContainerId> for &str {
ContainerId(self.to_string())
}
}
impl Into<ContainerId> 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<DirectoryId> for &str {
DirectoryId(self.to_string())
}
}
impl Into<DirectoryId> 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<FileId> for &str {
FileId(self.to_string())
}
}
impl Into<FileId> 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<Platform> for &str {
Platform(self.to_string())
}
}
impl Into<Platform> 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<SecretId> for &str {
SecretId(self.to_string())
}
}
impl Into<SecretId> 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<SocketId> for &str {
SocketId(self.to_string())
}
}
impl Into<SocketId> for String {
fn into(self) -> SocketId {
SocketId(self.clone())
}
}
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub struct BuildArg {
pub name: String,