Struct slack_messaging::blocks::elements::TimePicker
source · pub struct TimePicker { /* private fields */ }Expand description
Time picker element representation.
Example
use slack_messaging::blocks::elements::TimePicker;
use serde_json::json;
let timepicker = TimePicker::new()
.set_action_id("timepicker123")
.set_initial_time("11:30")
.set_timezone("Asia/Tokyo")
.placeholder("Select a time");
let expected = json!({
"type": "timepicker",
"action_id": "timepicker123",
"initial_time": "11:30",
"timezone": "Asia/Tokyo",
"placeholder": {
"type": "plain_text",
"text": "Select a time",
"emoji": true
}
});
let timepicker_json = serde_json::to_value(timepicker).unwrap();
assert_eq!(timepicker_json, expected);Implementations§
source§impl TimePicker
impl TimePicker
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a Time picker element with empty values.
use slack_messaging::blocks::elements::TimePicker;
use serde_json::json;
let timepicker = TimePicker::new();
let expected = json!({
"type": "timepicker",
"action_id": ""
});
let timepicker_json = serde_json::to_value(timepicker).unwrap();
assert_eq!(timepicker_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::TimePicker;
use serde_json::json;
let timepicker = TimePicker::new().set_action_id("timepicker123");
let expected = json!({
"type": "timepicker",
"action_id": "timepicker123"
});
let timepicker_json = serde_json::to_value(timepicker).unwrap();
assert_eq!(timepicker_json, expected);sourcepub fn set_initial_time<T: Into<String>>(self, value: T) -> Self
pub fn set_initial_time<T: Into<String>>(self, value: T) -> Self
Sets initial_time field.
use slack_messaging::blocks::elements::TimePicker;
use serde_json::json;
let timepicker = TimePicker::new().set_initial_time("11:00");
let expected = json!({
"type": "timepicker",
"action_id": "",
"initial_time": "11:00"
});
let timepicker_json = serde_json::to_value(timepicker).unwrap();
assert_eq!(timepicker_json, expected);sourcepub fn set_confirm(self, confirm: ConfirmationDialog) -> Self
pub fn set_confirm(self, confirm: ConfirmationDialog) -> Self
Sets confirm field with ConfirmationDialog.
use slack_messaging::blocks::elements::{TimePicker, ConfirmationDialog};
use serde_json::json;
let timepicker = TimePicker::new()
.set_confirm(
ConfirmationDialog::new()
.set_title("Are you sure?")
.set_text("Wouldn't you prefer a good game of _chess_?")
.set_confirm("Do it")
.set_deny("Stop, I've changed my mind!")
);
let expected = json!({
"type": "timepicker",
"action_id": "",
"confirm": {
"title": {
"type": "plain_text",
"text": "Are you sure?",
"emoji": true
},
"text": {
"type": "plain_text",
"text": "Wouldn't you prefer a good game of _chess_?",
"emoji": true
},
"confirm": {
"type": "plain_text",
"text": "Do it",
"emoji": true
},
"deny": {
"type": "plain_text",
"text": "Stop, I've changed my mind!",
"emoji": true
}
}
});
let timepicker_json = serde_json::to_value(timepicker).unwrap();
assert_eq!(timepicker_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::TimePicker;
use serde_json::json;
let timepicker = TimePicker::new().set_focus_on_load(true);
let expected = json!({
"type": "timepicker",
"action_id": "",
"focus_on_load": true
});
let timepicker_json = serde_json::to_value(timepicker).unwrap();
assert_eq!(timepicker_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::{TimePicker, Text};
use serde_json::json;
let timepicker = TimePicker::new()
.set_placeholder(Text::plain("Select a time"));
let expected = json!({
"type": "timepicker",
"action_id": "",
"placeholder": {
"type": "plain_text",
"text": "Select a time",
"emoji": true
}
});
let timepicker_json = serde_json::to_value(timepicker).unwrap();
assert_eq!(timepicker_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::TimePicker;
use serde_json::json;
let timepicker = TimePicker::new().placeholder("Select a time");
let expected = json!({
"type": "timepicker",
"action_id": "",
"placeholder": {
"type": "plain_text",
"text": "Select a time",
"emoji": true
}
});
let timepicker_json = serde_json::to_value(timepicker).unwrap();
assert_eq!(timepicker_json, expected);sourcepub fn set_timezone<T: Into<String>>(self, value: T) -> Self
pub fn set_timezone<T: Into<String>>(self, value: T) -> Self
Sets timezone field.
use slack_messaging::blocks::elements::TimePicker;
use serde_json::json;
let timepicker = TimePicker::new().set_timezone("Asia/Tokyo");
let expected = json!({
"type": "timepicker",
"action_id": "",
"timezone": "Asia/Tokyo"
});
let timepicker_json = serde_json::to_value(timepicker).unwrap();
assert_eq!(timepicker_json, expected);Trait Implementations§
source§impl Clone for TimePicker
impl Clone for TimePicker
source§fn clone(&self) -> TimePicker
fn clone(&self) -> TimePicker
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 TimePicker
impl Debug for TimePicker
source§impl Default for TimePicker
impl Default for TimePicker
source§impl From<TimePicker> for Accessory
impl From<TimePicker> for Accessory
source§fn from(value: TimePicker) -> Self
fn from(value: TimePicker) -> Self
Converts to this type from the input type.
source§impl From<TimePicker> for ActionsElement
impl From<TimePicker> for ActionsElement
source§fn from(value: TimePicker) -> Self
fn from(value: TimePicker) -> Self
Converts to this type from the input type.
source§impl From<TimePicker> for InputElement
impl From<TimePicker> for InputElement
source§fn from(value: TimePicker) -> Self
fn from(value: TimePicker) -> Self
Converts to this type from the input type.