Skip to main content

aws_sdk_amplifyuibuilder/types/
_component_event.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Describes the configuration of an event. You can bind an event and a corresponding action to a <code>Component</code> or a <code>ComponentChild</code>. A button click is an example of an event.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct ComponentEvent {
7    /// <p>The action to perform when a specific event is raised.</p>
8    pub action: ::std::option::Option<::std::string::String>,
9    /// <p>Describes information about the action.</p>
10    pub parameters: ::std::option::Option<crate::types::ActionParameters>,
11    /// <p>Binds an event to an action on a component. When you specify a <code>bindingEvent</code>, the event is called when the action is performed.</p>
12    pub binding_event: ::std::option::Option<::std::string::String>,
13}
14impl ComponentEvent {
15    /// <p>The action to perform when a specific event is raised.</p>
16    pub fn action(&self) -> ::std::option::Option<&str> {
17        self.action.as_deref()
18    }
19    /// <p>Describes information about the action.</p>
20    pub fn parameters(&self) -> ::std::option::Option<&crate::types::ActionParameters> {
21        self.parameters.as_ref()
22    }
23    /// <p>Binds an event to an action on a component. When you specify a <code>bindingEvent</code>, the event is called when the action is performed.</p>
24    pub fn binding_event(&self) -> ::std::option::Option<&str> {
25        self.binding_event.as_deref()
26    }
27}
28impl ComponentEvent {
29    /// Creates a new builder-style object to manufacture [`ComponentEvent`](crate::types::ComponentEvent).
30    pub fn builder() -> crate::types::builders::ComponentEventBuilder {
31        crate::types::builders::ComponentEventBuilder::default()
32    }
33}
34
35/// A builder for [`ComponentEvent`](crate::types::ComponentEvent).
36#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
37#[non_exhaustive]
38pub struct ComponentEventBuilder {
39    pub(crate) action: ::std::option::Option<::std::string::String>,
40    pub(crate) parameters: ::std::option::Option<crate::types::ActionParameters>,
41    pub(crate) binding_event: ::std::option::Option<::std::string::String>,
42}
43impl ComponentEventBuilder {
44    /// <p>The action to perform when a specific event is raised.</p>
45    pub fn action(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
46        self.action = ::std::option::Option::Some(input.into());
47        self
48    }
49    /// <p>The action to perform when a specific event is raised.</p>
50    pub fn set_action(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
51        self.action = input;
52        self
53    }
54    /// <p>The action to perform when a specific event is raised.</p>
55    pub fn get_action(&self) -> &::std::option::Option<::std::string::String> {
56        &self.action
57    }
58    /// <p>Describes information about the action.</p>
59    pub fn parameters(mut self, input: crate::types::ActionParameters) -> Self {
60        self.parameters = ::std::option::Option::Some(input);
61        self
62    }
63    /// <p>Describes information about the action.</p>
64    pub fn set_parameters(mut self, input: ::std::option::Option<crate::types::ActionParameters>) -> Self {
65        self.parameters = input;
66        self
67    }
68    /// <p>Describes information about the action.</p>
69    pub fn get_parameters(&self) -> &::std::option::Option<crate::types::ActionParameters> {
70        &self.parameters
71    }
72    /// <p>Binds an event to an action on a component. When you specify a <code>bindingEvent</code>, the event is called when the action is performed.</p>
73    pub fn binding_event(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
74        self.binding_event = ::std::option::Option::Some(input.into());
75        self
76    }
77    /// <p>Binds an event to an action on a component. When you specify a <code>bindingEvent</code>, the event is called when the action is performed.</p>
78    pub fn set_binding_event(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
79        self.binding_event = input;
80        self
81    }
82    /// <p>Binds an event to an action on a component. When you specify a <code>bindingEvent</code>, the event is called when the action is performed.</p>
83    pub fn get_binding_event(&self) -> &::std::option::Option<::std::string::String> {
84        &self.binding_event
85    }
86    /// Consumes the builder and constructs a [`ComponentEvent`](crate::types::ComponentEvent).
87    pub fn build(self) -> crate::types::ComponentEvent {
88        crate::types::ComponentEvent {
89            action: self.action,
90            parameters: self.parameters,
91            binding_event: self.binding_event,
92        }
93    }
94}