patternfly_yew/utils/
action.rs1use yew::prelude::*;
2
3#[derive(Clone, PartialEq, Default, Debug)]
5pub struct Action {
6 pub label: String,
8 pub callback: Callback<()>,
10}
11
12impl Action {
13 pub fn new<S>(label: S, callback: Callback<()>) -> Self
14 where
15 S: ToString,
16 {
17 Self {
18 label: label.to_string(),
19 callback,
20 }
21 }
22}
23
24pub trait IntoAction {
26 fn into_action<S: ToString>(self, label: S) -> Action;
27}
28
29impl IntoAction for Callback<()> {
30 fn into_action<S>(self, label: S) -> Action
31 where
32 S: ToString,
33 {
34 Action::new(label, self)
35 }
36}