Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert: conversion strategies for struct unions #21

Open
kristoff-it opened this issue Mar 2, 2024 · 0 comments
Open

convert: conversion strategies for struct unions #21

kristoff-it opened this issue Mar 2, 2024 · 0 comments

Comments

@kristoff-it
Copy link
Owner

At the moment, given the following files, conversion will succeed:

build.json

{
        "name": "zine",
        "version": "0.0.1"
        "dependencies": {
                "foo": {
                        "Remote": {
                                "url": "https",
                                "hash": "aaa"
                        }
                },
                "bar": {
                        "Local": {
                                "path": "/usr"
                        }
                }
        }
}

build.ziggy-schema

root = Project

struct Project {
    name: bytes,
    version: bytes,
    dependencies: map[Remote | Local],
}

struct Remote {
   url: bytes,
   hash: bytes,   
}

struct Local {
  path: bytes,
} 

Result:

{
    .name = "zine",
    .version = "0.0.1",
    .dependencies = {
        "foo": Remote {
            .url = "https",
            .hash = "aaa",
        },
        "bar": Local {
            .path = "/usr",
        },
    },
}

The goal is to also make the following JSON files succeed at importing:

Shape matching:

{
	"name": "zine",
	"version": "0.0.1"
	"dependencies": {
		"foo": {
			"url": "https",
			"hash": "aaa"
		},
		"bar": {
			"path": "/usr"
		}
	}
}

type field:

{
	"name": "zine",
	"version": "0.0.1"
	"dependencies": {
		"foo": {
			"type": "Remote",
			"url": "https",
			"hash": "aaa"
		},
		"bar": {
			"type": "Local",
			"path": "/usr"
		}
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant