pub struct FormattedMessage { /* private fields */ }Expand description
A formatted message ready to be sent to an external platform.
The body field contains the platform-specific payload (JSON string,
Markdown text, etc.). content_type tells the subscriber which
Content-Type header to use when delivering.
§Examples
use ironflow_engine::notify::FormattedMessage;
let message = FormattedMessage::json(r#"{"text":"hello"}"#);
assert_eq!(message.content_type(), "application/json");Implementations§
Source§impl FormattedMessage
impl FormattedMessage
Sourcepub fn new(body: &str, content_type: &'static str) -> Self
pub fn new(body: &str, content_type: &'static str) -> Self
Create a message with an explicit content type.
§Examples
use ironflow_engine::notify::FormattedMessage;
let msg = FormattedMessage::new("hello", "text/plain");
assert_eq!(msg.body(), "hello");
assert_eq!(msg.content_type(), "text/plain");Sourcepub fn json(body: &str) -> Self
pub fn json(body: &str) -> Self
Create a JSON message (application/json).
§Examples
use ironflow_engine::notify::FormattedMessage;
let msg = FormattedMessage::json(r#"{"text":"hello"}"#);
assert_eq!(msg.content_type(), "application/json");Sourcepub fn text(body: &str) -> Self
pub fn text(body: &str) -> Self
Create a plain text message (text/plain).
§Examples
use ironflow_engine::notify::FormattedMessage;
let msg = FormattedMessage::text("hello");
assert_eq!(msg.content_type(), "text/plain");Sourcepub fn content_type(&self) -> &'static str
pub fn content_type(&self) -> &'static str
The MIME content type.
Trait Implementations§
Source§impl Clone for FormattedMessage
impl Clone for FormattedMessage
Source§fn clone(&self) -> FormattedMessage
fn clone(&self) -> FormattedMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FormattedMessage
impl RefUnwindSafe for FormattedMessage
impl Send for FormattedMessage
impl Sync for FormattedMessage
impl Unpin for FormattedMessage
impl UnsafeUnpin for FormattedMessage
impl UnwindSafe for FormattedMessage
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