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

#[postcard(crate = ...)] analogous to #[serde(crate = "...")] #183

Closed
max-heller opened this issue Nov 16, 2024 · 1 comment · Fixed by #186
Closed

#[postcard(crate = ...)] analogous to #[serde(crate = "...")] #183

max-heller opened this issue Nov 16, 2024 · 1 comment · Fixed by #186

Comments

@max-heller
Copy link
Collaborator

Analogous to #[serde(crate = "...")], it'd be great to have a #[postcard(crate = ...)] for #[derive(Schema)] to make it possible to re-export postcard derives from another crate without needing an additional direct dependency on postcard or postcard_schema.

This

impl #impl_generics ::postcard_schema::Schema for #name #ty_generics #where_clause {
const SCHEMA: &'static ::postcard_schema::schema::NamedType = #ty;
}

would have to become something like

impl #impl_generics #postcard::Schema for #name #ty_generics #where_clause {
    const SCHEMA: &'static #postcard::schema::NamedType = #ty;
}

Parsing could likely be handled similarly to #154, although it'd be nice to support #[postcard(crate = postcard)] instead of requiring a string literal like #[postcard(crate = "postcard")] (IIRC, the reason serde uses string literals is for backwards-compatibility).

@jamesmunns
Copy link
Owner

I'm open to a PR for this!

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

Successfully merging a pull request may close this issue.

2 participants