pub struct TaskCard { /* private fields */ }Expand description
Task card representation.
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| task_id | String | Yes | N/A |
| title | String | Yes | N/A |
| details | RichText | No | Have exactly one element |
| output | RichText | No | Have exactly one element |
| sources | Vec<UrlSource> | No | N/A |
| status | TaskStatus | No | N/A |
| block_id | String | No | Maximum 255 characters |
§Example
The following is reproduction of the sample task card.
use slack_messaging::blocks::{RichText, TaskCard, TaskStatus};
use slack_messaging::blocks::elements::UrlSource;
use slack_messaging::blocks::rich_text::RichTextSection;
use slack_messaging::blocks::rich_text::types::RichTextElementText;
let task_card = TaskCard::builder()
.task_id("task_1")
.title("Fetching weather data")
.status(TaskStatus::Pending)
.output(
RichText::builder()
.element(
RichTextSection::builder()
.element(
RichTextElementText::builder()
.text("Found weather data for Chicago from 2 sources")
.build()?
)
.build()?
)
.build()?
)
.source(
UrlSource::builder()
.url("https://weather.com/")
.text("weather.com")
.build()?
)
.source(
UrlSource::builder()
.url("https://www.accuweather.com/")
.text("accuweather.com")
.build()?
)
.build()?;
let expected = serde_json::json!({
"type": "task_card",
"task_id": "task_1",
"title": "Fetching weather data",
"status": "pending",
"output": {
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Found weather data for Chicago from 2 sources"
}
]
}
]
},
"sources": [
{
"type": "url",
"url": "https://weather.com/",
"text": "weather.com"
},
{
"type": "url",
"url": "https://www.accuweather.com/",
"text": "accuweather.com"
}
]
});
let json = serde_json::to_value(task_card).unwrap();
assert_eq!(json, expected);Implementations§
Source§impl TaskCard
impl TaskCard
Sourcepub fn builder() -> TaskCardBuilder
pub fn builder() -> TaskCardBuilder
constract TaskCardBuilder object.
Trait Implementations§
impl StructuralPartialEq for TaskCard
Auto Trait Implementations§
impl Freeze for TaskCard
impl RefUnwindSafe for TaskCard
impl Send for TaskCard
impl Sync for TaskCard
impl Unpin for TaskCard
impl UnsafeUnpin for TaskCard
impl UnwindSafe for TaskCard
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