raiden-dynamo icon indicating copy to clipboard operation
raiden-dynamo copied to clipboard

custom from / into attribute

Open bokuweb opened this issue 5 years ago • 2 comments

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 avatar Jul 31 '20 15:07 bokuweb

#[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 avatar Mar 21 '21 17:03 bokuweb

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
  }
}

bokuweb avatar Mar 21 '21 17:03 bokuweb