pub struct Context { /* private fields */ }Expand description
Context block representation.
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| elements | Vec<ContextElement> | Yes | Max 10 items |
| block_id | String | No | Maximum 255 characters |
§Example
The following is reproduction of the sample context.
use slack_messaging::mrkdwn;
use slack_messaging::blocks::Context;
use slack_messaging::blocks::elements::Image;
let context = Context::builder()
.element(
Image::builder()
.image_url("https://image.freepik.com/free-photo/red-drawing-pin_1156-445.jpg")
.alt_text("images")
.build()?
)
.element(mrkdwn!("Location: **Dogpatch**")?)
.build()?;
let expected = serde_json::json!({
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://image.freepik.com/free-photo/red-drawing-pin_1156-445.jpg",
"alt_text": "images"
},
{
"type": "mrkdwn",
"text": "Location: **Dogpatch**"
}
]
});
let json = serde_json::to_value(context).unwrap();
assert_eq!(json, expected);Implementations§
Source§impl Context
impl Context
Sourcepub fn builder() -> ContextBuilder
pub fn builder() -> ContextBuilder
constract ContextBuilder object.
Trait Implementations§
impl StructuralPartialEq for Context
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
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)