pub struct TextObject<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.
§TextObject<Plain> or alias PlainText
| Field | Type | Required | Validation |
|---|---|---|---|
| text | String | Yes | Minimum length: 1 character, Maximum length: 3000 characters. |
| emoji | bool | No | N/A |
§TextObject<Mrkdwn> or alias MrkdwnText
| 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::{PlainText, MrkdwnText};
// 1. Plain Text Object
let plain_text = PlainText::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 = MrkdwnText::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> TextObject<T>
impl<T> TextObject<T>
Sourcepub fn builder() -> TextObjectBuilder<T>
pub fn builder() -> TextObjectBuilder<T>
constract TextObjectBuilder object.
Trait Implementations§
Source§impl<T: Clone> Clone for TextObject<T>
impl<T: Clone> Clone for TextObject<T>
Source§fn clone(&self) -> TextObject<T>
fn clone(&self) -> TextObject<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for TextObject<T>
impl<T: Debug> Debug for TextObject<T>
Source§impl From<TextObject<Mrkdwn>> for Text
impl From<TextObject<Mrkdwn>> for Text
Source§fn from(text: TextObject<Mrkdwn>) -> Self
fn from(text: TextObject<Mrkdwn>) -> Self
Converts to this type from the input type.
Source§impl From<TextObject<Plain>> for Text
impl From<TextObject<Plain>> for Text
Source§fn from(text: TextObject<Plain>) -> Self
fn from(text: TextObject<Plain>) -> Self
Converts to this type from the input type.
Source§impl PartialEq for TextObject<Plain>
impl PartialEq for TextObject<Plain>
Source§impl PartialEq for TextObject<Mrkdwn>
impl PartialEq for TextObject<Mrkdwn>
Source§impl Serialize for TextObject<Plain>
impl Serialize for TextObject<Plain>
Source§impl Serialize for TextObject<Mrkdwn>
impl Serialize for TextObject<Mrkdwn>
Auto Trait Implementations§
impl<T> Freeze for TextObject<T>
impl<T> RefUnwindSafe for TextObject<T>where
T: RefUnwindSafe,
impl<T> Send for TextObject<T>where
T: Send,
impl<T> Sync for TextObject<T>where
T: Sync,
impl<T> Unpin for TextObject<T>where
T: Unpin,
impl<T> UnsafeUnpin for TextObject<T>
impl<T> UnwindSafe for TextObject<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more