Struct slack_messaging::blocks::elements::PlainTextInput
source · pub struct PlainTextInput { /* private fields */ }Expand description
Plain-text input element representation.
Example
use slack_messaging::blocks::elements::PlainTextInput;
use serde_json::json;
let plain = PlainTextInput::new()
.set_action_id("plain_input")
.multiline()
.placeholder("Enter some plain text");
let expected = json!({
"type": "plain_text_input",
"action_id": "plain_input",
"multiline": true,
"placeholder": {
"type": "plain_text",
"text": "Enter some plain text",
"emoji": true
}
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_json, expected);Implementations§
source§impl PlainTextInput
impl PlainTextInput
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a Plain-text input element with empty values.
use slack_messaging::blocks::elements::PlainTextInput;
use serde_json::json;
let plain = PlainTextInput::new();
let expected = json!({
"type": "plain_text_input",
"action_id": ""
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_json, expected);sourcepub fn set_action_id<T: Into<String>>(self, value: T) -> Self
pub fn set_action_id<T: Into<String>>(self, value: T) -> Self
Sets action_id field.
use slack_messaging::blocks::elements::PlainTextInput;
use serde_json::json;
let plain = PlainTextInput::new().set_action_id("plain_input");
let expected = json!({
"type": "plain_text_input",
"action_id": "plain_input"
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_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::PlainTextInput;
use serde_json::json;
let plain = PlainTextInput::new().set_initial_value("some value");
let expected = json!({
"type": "plain_text_input",
"action_id": "",
"initial_value": "some value"
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_json, expected);sourcepub fn set_multiline(self, value: bool) -> Self
pub fn set_multiline(self, value: bool) -> Self
Sets multiline field.
use slack_messaging::blocks::elements::PlainTextInput;
use serde_json::json;
let plain = PlainTextInput::new().set_multiline(false);
let expected = json!({
"type": "plain_text_input",
"action_id": "",
"multiline": false
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_json, expected);sourcepub fn multiline(self) -> Self
pub fn multiline(self) -> Self
Sets true to multiline field.
use slack_messaging::blocks::elements::PlainTextInput;
use serde_json::json;
let plain = PlainTextInput::new().multiline();
let expected = json!({
"type": "plain_text_input",
"action_id": "",
"multiline":true
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_json, expected);sourcepub fn set_min_length<T: Into<i64>>(self, value: T) -> Self
pub fn set_min_length<T: Into<i64>>(self, value: T) -> Self
Sets min_length field.
use slack_messaging::blocks::elements::PlainTextInput;
use serde_json::json;
let plain = PlainTextInput::new().set_min_length(10);
let expected = json!({
"type": "plain_text_input",
"action_id": "",
"min_length": 10
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_json, expected);sourcepub fn set_max_length<T: Into<i64>>(self, value: T) -> Self
pub fn set_max_length<T: Into<i64>>(self, value: T) -> Self
Sets max_length field.
use slack_messaging::blocks::elements::PlainTextInput;
use serde_json::json;
let plain = PlainTextInput::new().set_max_length(200);
let expected = json!({
"type": "plain_text_input",
"action_id": "",
"max_length": 200
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_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.
use slack_messaging::blocks::elements::{PlainTextInput, DispatchActionConfiguration,
TriggerAction};
use serde_json::json;
let plain = PlainTextInput::new()
.set_dispatch_action_config(
DispatchActionConfiguration::new()
.push_trigger_action(TriggerAction::OnCharacterEntered)
);
let expected = json!({
"type": "plain_text_input",
"action_id": "",
"dispatch_action_config": {
"trigger_actions_on": ["on_character_entered"]
}
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_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::PlainTextInput;
use serde_json::json;
let plain = PlainTextInput::new().set_focus_on_load(true);
let expected = json!({
"type": "plain_text_input",
"action_id": "",
"focus_on_load": true
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_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::{PlainTextInput, Text};
use serde_json::json;
let plain = PlainTextInput::new()
.set_placeholder(Text::plain("Enter some plain text"));
let expected = json!({
"type": "plain_text_input",
"action_id": "",
"placeholder": {
"type": "plain_text",
"text": "Enter some plain text",
"emoji": true
}
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_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::PlainTextInput;
use serde_json::json;
let plain = PlainTextInput::new().placeholder("Enter some plain text");
let expected = json!({
"type": "plain_text_input",
"action_id": "",
"placeholder": {
"type": "plain_text",
"text": "Enter some plain text",
"emoji": true
}
});
let plain_json = serde_json::to_value(plain).unwrap();
assert_eq!(plain_json, expected);Trait Implementations§
source§impl Clone for PlainTextInput
impl Clone for PlainTextInput
source§fn clone(&self) -> PlainTextInput
fn clone(&self) -> PlainTextInput
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 PlainTextInput
impl Debug for PlainTextInput
source§impl Default for PlainTextInput
impl Default for PlainTextInput
source§impl From<PlainTextInput> for InputElement
impl From<PlainTextInput> for InputElement
source§fn from(value: PlainTextInput) -> Self
fn from(value: PlainTextInput) -> Self
Converts to this type from the input type.