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

custom from / into attribute #79

Open
bokuweb opened this issue Jul 31, 2020 · 2 comments
Open

custom from / into attribute #79

bokuweb opened this issue Jul 31, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@bokuweb
Copy link
Member

bokuweb commented Jul 31, 2020

Is your feature request related to a problem? Please describe.

I'd like to support custom from / into attribute function.

Describe the solution you'd like

Can this feature be realized by the following?

#[derive(Raiden)]
struct Foo {
  id: String
  #[raiden(from_fn(custom_fn))]
  greeting: String
}

fn custom_fn(value: Option<raiden::AttributeValue>) -> Result<String, RaidenError>  {
  // ... convert attribute to String
}

Describe alternatives you've considered

NA

Additional context

NA

@bokuweb bokuweb added the enhancement New feature or request label Jul 31, 2020
@bokuweb
Copy link
Member Author

bokuweb commented Mar 21, 2021

#[derive(Raiden)]
struct Foo {
  id: String
  #[raiden(from_attr_fn(custom_fn))]
  greeting: String
}

impl Foo {
  fn custom_attr_fn(value: Option<raiden::AttributeValue>) -> Result<String, RaidenError>  {
    // ... convert attribute to String
  }
}

@bokuweb
Copy link
Member Author

bokuweb commented Mar 21, 2021

I'd like to add from_attr_map_fn like following too.

#[derive(Raiden)]
struct Foo {
  id: String
  #[raiden(from_attr_map_fn(custom_fn))]
  greeting: String
}

impl Foo {
  fn custom_attr_map_fn(map: &HashMap<String, AttributeValue>) -> Result<String, RaidenError>  {
    // ... convert attribute to String
  }
}

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
None yet
Development

No branches or pull requests

1 participant