pub struct Table { /* private fields */ }Expand description
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<TableRow> | Yes | Maximum 100 items |
| column_settings | Vec<ColumnSetting> | No | Maximum 20 items |
§Example
use slack_messaging::blocks::{RichText, Table};
use slack_messaging::blocks::rich_text::{types::RichTextElementLink, RichTextSection};
use slack_messaging::blocks::table::{ColumnAlignment, ColumnSetting, TableRow};
let table = Table::builder()
.block_id("table_1")
.row(
TableRow::builder()
.cell("Header A")
.cell("Header B")
.build()?
)
.row(
TableRow::builder()
.cell("Data 1A")
.cell(
RichText::builder()
.element(
RichTextSection::builder()
.element(
RichTextElementLink::builder()
.text("Data 1B")
.url("https://slack.com")
.build()?
)
.build()?
)
.build()?
)
.build()?
)
.column_setting(
ColumnSetting::builder()
.is_wrapped(true)
.build()?
)
.column_setting(
ColumnSetting::builder()
.align(ColumnAlignment::Right)
.build()?
)
.build()?;
let expected = serde_json::json!({
"type": "table",
"block_id": "table_1",
"column_settings": [
{
"is_wrapped": true
},
{
"align": "right"
}
],
"rows": [
[
{
"type": "raw_text",
"text": "Header A"
},
{
"type": "raw_text",
"text": "Header B"
}
],
[
{
"type": "raw_text",
"text": "Data 1A"
},
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "link",
"text": "Data 1B",
"url": "https://slack.com"
}
]
}
]
}
]
]
});
let json = serde_json::to_value(table).unwrap();
assert_eq!(json, expected);Implementations§
Source§impl Table
impl Table
Sourcepub fn builder() -> TableBuilder
pub fn builder() -> TableBuilder
constract TableBuilder object.
Trait Implementations§
impl StructuralPartialEq for Table
Auto Trait Implementations§
impl Freeze for Table
impl RefUnwindSafe for Table
impl Send for Table
impl Sync for Table
impl Unpin for Table
impl UnwindSafe for Table
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)