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

ItemId: API design #158

Closed
azriel91 opened this issue Jun 28, 2023 · 0 comments · Fixed by #181
Closed

ItemId: API design #158

azriel91 opened this issue Jun 28, 2023 · 0 comments · Fixed by #181

Comments

@azriel91
Copy link
Owner

Enables developers to not use strings, and peace to not clone everywhere.

Currently ItemId is a Cow<'_, str> newtype. If we instead require developers to provide something like:

#[derive(ItemIds)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum EnvDeployFlowItemIds {
    ProfileS3Bucket,
    WebAppDownload,
    WebAppS3ObjectUpload,
}

for which peace generates:

// for each variant
#[derive(Deserialize, Serialize)]
pub struct ProfileS3Bucket;

impl EnvDeployFlowItemIds From<ProfileS3Bucket> {}
impl ProfileS3Bucket TryFrom<EnvDeployFlowItemIds> {}
impl Display for ProfileS3Bucket {} // maybe

then code will be a bit more robust, though it does entail defining the enum everywhere you write tests.

Need to also consider upgrades: additions, removals, and renames.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant