#[derive(Element)]
{
// Attributes available to this derive:
#[element]
}
Expand description
feature = derive (default)
Derives a redact-composer
Element
impl for this type.
The default implementation (which likely satisfies the majority of cases) is nothing more than:
#[typetag::serde] // If "serde" feature enabled
impl Element for MyElement {}
Important!: At the current time, if using the
serde
feature (enabled by default), in order to use this derive macro you need to have [typetag
] added as a dependency to your crate.
Additional options (if needed) are specified via the #[element(params)]
attribute which accepts
any of the following params:
-
feature: serde
name: String
: Provides a different serialization name if you need to avoid naming collisions or just prefer something different. In either case, this name is just passed along to#[typetag::serde(name = name)]
.Default: the type’s name.
-
wrapped_element: Expr
: If you are creating an Element that wraps another you can specify the expression to access it (e.g.Some(self.wrapped_item())
). The expression should return anOption<&dyn Element>
.Default:
None
. -
wrapped_element_doc: String
: Use this to provide a doc comment (no /// necessary) for the wrapped element. Only has an effect ifwrapped_element
is also present.