pub struct Text<T> { /* private fields */ }Expand description
Text object representation.
This is a generic struct that can represent either a plain text object or a markdown text
object, depending on the type parameter T.
§Type Parameters
§Fields and Validations
For more details, see the Slack API documentation.
§Text<Plain>
| Field | Type | Required | Validation |
|---|---|---|---|
| text | String | Yes | Minimum length: 1 character, Maximum length: 3000 characters. |
| emoji | bool | No | N/A |
§Text<Mrkdwn>
| Field | Type | Required | Validation |
|---|---|---|---|
| text | String | Yes | Minimum length: 1 character, Maximum length: 3000 characters. |
| verbatim | bool | No | N/A |
§Example
use slack_messaging::composition_objects::{Text, Plain, Mrkdwn};
// 1. Plain Text Object
let plain_text = Text::<Plain>::builder()
.text("Hello, World!")
.emoji(true)
.build()?;
let plain_json = serde_json::to_value(plain_text).unwrap();
let expected_plain = serde_json::json!({
"type": "plain_text",
"text": "Hello, World!",
"emoji": true
});
assert_eq!(plain_json, expected_plain);
// 2. Markdown Text Object
let mrkdwn_text = Text::<Mrkdwn>::builder()
.text("*Hello*, _World_!")
.verbatim(false)
.build()?;
let mrkdwn_json = serde_json::to_value(mrkdwn_text).unwrap();
let expected_mrkdwn = serde_json::json!({
"type": "mrkdwn",
"text": "*Hello*, _World_!",
"verbatim": false
});
assert_eq!(mrkdwn_json, expected_mrkdwn);Implementations§
Source§impl<T> Text<T>
impl<T> Text<T>
Sourcepub fn builder() -> TextBuilder<T>
pub fn builder() -> TextBuilder<T>
constract TextBuilder object.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Text<T>
impl<T> RefUnwindSafe for Text<T>where
T: RefUnwindSafe,
impl<T> Send for Text<T>where
T: Send,
impl<T> Sync for Text<T>where
T: Sync,
impl<T> Unpin for Text<T>where
T: Unpin,
impl<T> UnwindSafe for Text<T>where
T: UnwindSafe,
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)