Struct slack_messaging::blocks::elements::EmailInput
source · pub struct EmailInput { /* private fields */ }Expand description
Email input element representation.
Example
use slack_messaging::blocks::elements::EmailInput;
use serde_json::json;
let email = EmailInput::new()
.set_action_id("input_email")
.placeholder("Enter an email");
let expected = json!({
"type": "email_text_input",
"action_id": "input_email",
"placeholder": {
"type": "plain_text",
"text": "Enter an email",
"emoji": true
}
});
let email_json = serde_json::to_value(email).unwrap();
assert_eq!(email_json, expected);Implementations§
source§impl EmailInput
impl EmailInput
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a Email Input element with empty values.
use slack_messaging::blocks::elements::EmailInput;
use serde_json::json;
let email = EmailInput::new();
let expected = json!({
"type": "email_text_input",
"action_id": ""
});
let email_json = serde_json::to_value(email).unwrap();
assert_eq!(email_json, expected);sourcepub fn set_action_id<T: Into<String>>(self, action_id: T) -> Self
pub fn set_action_id<T: Into<String>>(self, action_id: T) -> Self
Sets action_id field.
use slack_messaging::blocks::elements::EmailInput;
use serde_json::json;
let email = EmailInput::new().set_action_id("input_email");
let expected = json!({
"type": "email_text_input",
"action_id": "input_email"
});
let email_json = serde_json::to_value(email).unwrap();
assert_eq!(email_json, expected);sourcepub fn set_initial_value<T: Into<String>>(self, value: T) -> Self
pub fn set_initial_value<T: Into<String>>(self, value: T) -> Self
Sets initial_value field.
use slack_messaging::blocks::elements::EmailInput;
use serde_json::json;
let email = EmailInput::new().set_initial_value("tanaka@gmail.com");
let expected = json!({
"type": "email_text_input",
"action_id": "",
"initial_value": "tanaka@gmail.com"
});
let email_json = serde_json::to_value(email).unwrap();
assert_eq!(email_json, expected);sourcepub fn set_dispatch_action_config(
self,
config: DispatchActionConfiguration
) -> Self
pub fn set_dispatch_action_config( self, config: DispatchActionConfiguration ) -> Self
Sets dispatch_action_config field with DispatchActionConfiguration.
use slack_messaging::blocks::elements::{EmailInput, DispatchActionConfiguration,
TriggerAction};
use serde_json::json;
let email = EmailInput::new()
.set_dispatch_action_config(
DispatchActionConfiguration::new()
.push_trigger_action(TriggerAction::OnEnterPressed)
);
let expected = json!({
"type": "email_text_input",
"action_id": "",
"dispatch_action_config": {
"trigger_actions_on": [
"on_enter_pressed"
]
}
});
let email_json = serde_json::to_value(email).unwrap();
assert_eq!(email_json, expected);sourcepub fn set_focus_on_load(self, focus_on_load: bool) -> Self
pub fn set_focus_on_load(self, focus_on_load: bool) -> Self
Sets focus_on_load field.
use slack_messaging::blocks::elements::EmailInput;
use serde_json::json;
let email = EmailInput::new().set_focus_on_load(true);
let expected = json!({
"type": "email_text_input",
"action_id": "",
"focus_on_load": true
});
let email_json = serde_json::to_value(email).unwrap();
assert_eq!(email_json, expected);sourcepub fn set_placeholder(self, placeholder: Text) -> Self
pub fn set_placeholder(self, placeholder: Text) -> Self
Sets placeholder field.
use slack_messaging::blocks::elements::{EmailInput, Text};
use serde_json::json;
let email = EmailInput::new().set_placeholder(Text::plain("Enter your email."));
let expected = json!({
"type": "email_text_input",
"action_id": "",
"placeholder": {
"type": "plain_text",
"text": "Enter your email.",
"emoji": true
}
});
let email_json = serde_json::to_value(email).unwrap();
assert_eq!(email_json, expected);sourcepub fn placeholder<T: Into<String>>(self, placeholder: T) -> Self
pub fn placeholder<T: Into<String>>(self, placeholder: T) -> Self
Sets placeholder field from string. This is a shorthand for set_placeholder method.
use slack_messaging::blocks::elements::EmailInput;
use serde_json::json;
let email = EmailInput::new().placeholder("Enter your email.");
let expected = json!({
"type": "email_text_input",
"action_id": "",
"placeholder": {
"type": "plain_text",
"text": "Enter your email.",
"emoji": true
}
});
let email_json = serde_json::to_value(email).unwrap();
assert_eq!(email_json, expected);Trait Implementations§
source§impl Clone for EmailInput
impl Clone for EmailInput
source§fn clone(&self) -> EmailInput
fn clone(&self) -> EmailInput
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for EmailInput
impl Debug for EmailInput
source§impl Default for EmailInput
impl Default for EmailInput
source§impl From<EmailInput> for InputElement
impl From<EmailInput> for InputElement
source§fn from(value: EmailInput) -> Self
fn from(value: EmailInput) -> Self
Converts to this type from the input type.