pub struct Image { /* private fields */ }Expand description
Image block representation.
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| alt_text | String | Yes | Maximum 2000 characters |
| image_url | String | Conditional* | Maximum 3000 characters |
| title | Text<Plain> | No | Maximum 2000 characters |
| block_id | String | No | Maximum 255 characters |
| slack_file | SlackFile | Conditional* | N/A |
§Validation Across Fields
- Either
image_urlorslack_fileis required. Both fields cannot be set simultaneously.
§Example
use slack_messaging::plain_text;
use slack_messaging::blocks::Image;
let image = Image::builder()
.block_id("image4")
.title(plain_text!("Please enjoy this photo of a kitten")?)
.image_url("http://placekitten.com/500/500")
.alt_text("An incredibly cute kitten.")
.build()?;
let expected = serde_json::json!({
"type": "image",
"block_id": "image4",
"title": {
"type": "plain_text",
"text": "Please enjoy this photo of a kitten"
},
"image_url": "http://placekitten.com/500/500",
"alt_text": "An incredibly cute kitten."
});
let json = serde_json::to_value(image).unwrap();
assert_eq!(json, expected);Implementations§
Source§impl Image
impl Image
Sourcepub fn builder() -> ImageBuilder
pub fn builder() -> ImageBuilder
constract ImageBuilder object.
Trait Implementations§
impl StructuralPartialEq for Image
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnwindSafe for Image
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)