Struct slack_messaging::MessageBuilder
source · pub struct MessageBuilder { /* private fields */ }
Expand description
Builder for Message
object.
Implementations§
source§impl MessageBuilder
impl MessageBuilder
sourcepub fn set_text(self, text: Option<String>) -> Self
pub fn set_text(self, text: Option<String>) -> Self
Set text field.
let message = Message::builder()
.set_text(Some("New Paid Time Off request from Fred Enriquez".into()))
.build();
let expected = serde_json::json!({
"text": "New Paid Time Off request from Fred Enriquez",
});
let json = serde_json::to_value(message).unwrap();
assert_eq!(json, expected);
sourcepub fn text(self, text: impl Into<String>) -> Self
pub fn text(self, text: impl Into<String>) -> Self
Set text field.
let message = Message::builder()
.text("New Paid Time Off request from Fred Enriquez")
.build();
let expected = serde_json::json!({
"text": "New Paid Time Off request from Fred Enriquez",
});
let json = serde_json::to_value(message).unwrap();
assert_eq!(json, expected);
sourcepub fn set_blocks(self, blocks: Vec<Block>) -> Self
pub fn set_blocks(self, blocks: Vec<Block>) -> Self
Set blocks field. The argument is a vector composed from any objects that can transform into the enum Block.
let message = Message::builder()
.set_blocks(
vec![
Header::builder()
.text("New request")
.build()
.into(),
Section::builder()
.text(mrkdwn!("<https://example.com|View request>"))
.build()
.into(),
]
)
.build();
let expected = serde_json::json!({
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "New request"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<https://example.com|View request>"
}
}
]
});
let json = serde_json::to_value(message).unwrap();
assert_eq!(json, expected);
sourcepub fn block(self, block: impl Into<Block>) -> Self
pub fn block(self, block: impl Into<Block>) -> Self
Add an object to blocks field. The argument is an any object that can transform into the enum Block.
let message = Message::builder()
.block(
Header::builder()
.text("New request")
.build()
)
.block(
Section::builder()
.text(mrkdwn!("<https://example.com|View request>"))
.build()
)
.build();
let expected = serde_json::json!({
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "New request"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<https://example.com|View request>"
}
}
]
});
let json = serde_json::to_value(message).unwrap();
assert_eq!(json, expected);
sourcepub fn set_thread_ts(self, thread_ts: Option<String>) -> Self
pub fn set_thread_ts(self, thread_ts: Option<String>) -> Self
Set thread_ts field.
let message = Message::builder()
.set_thread_ts(Some("some ts value".into()))
.build();
let expected = serde_json::json!({
"thread_ts": "some ts value",
});
let json = serde_json::to_value(message).unwrap();
assert_eq!(json, expected);
sourcepub fn thread_ts(self, thread_ts: impl Into<String>) -> Self
pub fn thread_ts(self, thread_ts: impl Into<String>) -> Self
Set thread_ts field.
let message = Message::builder()
.thread_ts("some ts value")
.build();
let expected = serde_json::json!({
"thread_ts": "some ts value",
});
let json = serde_json::to_value(message).unwrap();
assert_eq!(json, expected);
sourcepub fn set_mrkdwn(self, mrkdwn: Option<bool>) -> Self
pub fn set_mrkdwn(self, mrkdwn: Option<bool>) -> Self
Set mrkdwn field.
let message = Message::builder()
.set_mrkdwn(Some(true))
.build();
let expected = serde_json::json!({
"mrkdwn": true,
});
let json = serde_json::to_value(message).unwrap();
assert_eq!(json, expected);
sourcepub fn mrkdwn(self, mrkdwn: bool) -> Self
pub fn mrkdwn(self, mrkdwn: bool) -> Self
Set mrkdwn field.
let message = Message::builder()
.mrkdwn(true)
.build();
let expected = serde_json::json!({
"mrkdwn": true,
});
let json = serde_json::to_value(message).unwrap();
assert_eq!(json, expected);
sourcepub fn get_blocks(&self) -> &[Block]
pub fn get_blocks(&self) -> &[Block]
Get blocks value.
sourcepub fn get_thread_ts(&self) -> &Option<String>
pub fn get_thread_ts(&self) -> &Option<String>
Get thread_ts value.
sourcepub fn get_mrkdwn(&self) -> &Option<bool>
pub fn get_mrkdwn(&self) -> &Option<bool>
Get mrkdwn value.
Trait Implementations§
source§impl Debug for MessageBuilder
impl Debug for MessageBuilder
source§impl Default for MessageBuilder
impl Default for MessageBuilder
source§fn default() -> MessageBuilder
fn default() -> MessageBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MessageBuilder
impl RefUnwindSafe for MessageBuilder
impl Send for MessageBuilder
impl Sync for MessageBuilder
impl Unpin for MessageBuilder
impl UnwindSafe for MessageBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more