pub struct DataTable { /* private fields */ }Expand description
Data Table block representation.
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| block_id | String | No | Maximum 255 characters. |
| rows | Vec<DataTableRow> | Yes | Maximum 101 items (100 regular rows plus the header). Minimum 2 items (1 regular row plus the header). The first row is a header, and rich_text cannot be used for the header cells. |
| caption | String | Yes | N/A |
| page_size | i64 | No | Minimum 1, maximum 100. |
| row_header_column_index | i64 | No | Minimum 0. |
§Example
use slack_messaging::blocks::rich_text::prelude::*;
use slack_messaging::blocks::data_table::*;
let table = DataTable::builder()
.caption("A Fabulous Table")
.row(
DataTableRow::builder()
.cell("Name")
.cell("Department")
.cell("Badge")
.build()?
)
.row(
DataTableRow::builder()
.cell("Data Refinement Department")
.cell("MDR")
.cell(
RichText::builder()
.element(
RichTextSection::builder()
.element(
RichTextElementText::builder()
.text("Blue")
.style(
RichTextStyle::builder()
.bold(true)
.build()?
)
.build()?
)
.build()?
)
.build()?
)
.build()?
)
.row(
DataTableRow::builder()
.cell("Art Sourcing Department")
.cell("O&D")
.cell(
RichText::builder()
.element(
RichTextSection::builder()
.element(
RichTextElementText::builder()
.text("Green")
.build()?
)
.element(
RichTextElementText::builder()
.text("review")
.style(
RichTextStyle::builder()
.italic(true)
.build()?
)
.build()?
)
.build()?
)
.build()?
)
.build()?
)
.row(
DataTableRow::builder()
.cell("Wellness Department")
.cell("Wellness Center")
.cell(
RichText::builder()
.element(
RichTextSection::builder()
.element(
RichTextElementText::builder()
.text("Limited")
.style(
RichTextStyle::builder()
.bold(true)
.build()?
)
.build()?
)
.build()?
)
.build()?
)
.build()?
)
.build()?;
let expected = serde_json::json!({
"type": "data_table",
"caption": "A Fabulous Table",
"rows": [
[
{
"type": "raw_text",
"text": "Name"
},
{
"type": "raw_text",
"text": "Department"
},
{
"type": "raw_text",
"text": "Badge"
}
],
[
{
"type": "raw_text",
"text": "Data Refinement Department"
},
{
"type": "raw_text",
"text": "MDR"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Blue",
"style": {
"bold": true
}
}
]
}
]
}
],
[
{
"type": "raw_text",
"text": "Art Sourcing Department"
},
{
"type": "raw_text",
"text": "O&D"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Green"
},
{
"type": "text",
"text": "review",
"style": {
"italic": true
}
}
]
}
]
}
],
[
{
"type": "raw_text",
"text": "Wellness Department"
},
{
"type": "raw_text",
"text": "Wellness Center"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Limited",
"style": {
"bold": true
}
}
]
}
]
}
]
]
});
let json = serde_json::to_value(table).unwrap();
assert_eq!(json, expected);Implementations§
Source§impl DataTable
impl DataTable
Sourcepub fn builder() -> DataTableBuilder
pub fn builder() -> DataTableBuilder
constract DataTableBuilder object.
Trait Implementations§
impl StructuralPartialEq for DataTable
Auto Trait Implementations§
impl Freeze for DataTable
impl RefUnwindSafe for DataTable
impl Send for DataTable
impl Sync for DataTable
impl Unpin for DataTable
impl UnsafeUnpin for DataTable
impl UnwindSafe for DataTable
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