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

Add Derive for Api #235

Closed
ecton opened this issue Mar 30, 2022 · 3 comments · Fixed by #245
Closed

Add Derive for Api #235

ecton opened this issue Mar 30, 2022 · 3 comments · Fixed by #245
Labels
enhancement New feature or request
Milestone

Comments

@ecton
Copy link
Member

ecton commented Mar 30, 2022

The Api trait should be deriveable:

struct MyType;

impl Api for MyType {
  type Response = OtherType;
  type Error = bonsaidb::core::api::Infallible;

  fn name() -> ApiName {
    ApiName::new("authority", "name")
  }
}

Should be able to be derived as:

#[derive(Api)]
#[api(authority = "authority", name = "name", response = OtherType, error = Infallible]
struct MyType;

Response is required. Error should be optional. If not specified, it should use bonsaidb_core::api::Infallible. Authority can be optional the same way the other derives work.

@ModProg

@ecton ecton added the enhancement New feature or request label Mar 30, 2022
@ecton ecton added this to the v1.0 milestone Mar 30, 2022
@ecton ecton added this to To do in Khonsu Labs Roadmap via automation Mar 30, 2022
@ModProg
Copy link
Collaborator

ModProg commented Apr 15, 2022

bonsaidb_core::api::Infallible

probably should remember to change that to ! whenever that comes around 😆

@ecton
Copy link
Member Author

ecton commented Apr 15, 2022

probably should remember to change that to ! whenever that comes around

Only if Serde supports ! with Serialize/Deserialize, which I don't anticipate based on this closed issue. That's the primary reason for having a different type than std::convert::Infallible -- due to orphan rules I can't implement Serialize/Deserialize for std::convert::Infallible, and similarly, I wouldn't be able to for the never type either.

@ModProg
Copy link
Collaborator

ModProg commented Apr 15, 2022

That makes sense, but when ! is stabilized, it would probably make sense to ask serde to add an implementation for it again.

@ModProg ModProg mentioned this issue Apr 21, 2022
Khonsu Labs Roadmap automation moved this from To do to Done Apr 22, 2022
@ecton ecton modified the milestones: v1.0, v0.5.0 Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants