pub struct Image { /* private fields */ }Expand description
Image element representation.
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| alt_text | String | Yes | N/A |
| image_url | String | Conditional* | Max length 3000 characters |
| slack_file | SlackFile | Conditional* | N/A |
§Validation Across Fields
- Either
image_urlorslack_fileis required, but not both.
§Example
use slack_messaging::blocks::elements::Image;
let image = Image::builder()
.image_url("http://placekitten.com/700/500")
.alt_text("Multiple cute kittens")
.build()?;
let expected = serde_json::json!({
"type": "image",
"image_url": "http://placekitten.com/700/500",
"alt_text": "Multiple cute kittens"
});
let json = serde_json::to_value(image).unwrap();
assert_eq!(json, expected);
// If your object has any validation errors, the build method returns Result::Err
let image = Image::builder()
.image_url("http://placekitten.com/700/500")
.build();
assert!(image.is_err());Implementations§
Source§impl Image
impl Image
Sourcepub fn builder() -> ImageBuilder
pub fn builder() -> ImageBuilder
constract ImageBuilder object.
Trait Implementations§
Source§impl From<Image> for ContextElement
impl From<Image> for ContextElement
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)