pub struct SendOptions {
pub priority: Option<MessagePriority>,
pub flush: bool,
pub timeout: Option<Duration>,
}Expand description
Options for sending messages.
§Examples
use pmcp::shared::transport::{SendOptions, MessagePriority};
use std::time::Duration;
// Default options
let default_opts = SendOptions::default();
assert!(default_opts.priority.is_none());
assert!(!default_opts.flush);
assert!(default_opts.timeout.is_none());
// High priority message with immediate flush
let urgent_opts = SendOptions {
priority: Some(MessagePriority::High),
flush: true,
timeout: Some(Duration::from_secs(5)),
};
// Builder pattern for options
fn build_send_options(urgent: bool) -> SendOptions {
SendOptions {
priority: if urgent {
Some(MessagePriority::High)
} else {
Some(MessagePriority::Normal)
},
flush: urgent,
timeout: Some(Duration::from_secs(if urgent { 5 } else { 30 })),
}
}
let opts = build_send_options(true);
assert_eq!(opts.priority, Some(MessagePriority::High));
assert!(opts.flush);Fields§
§priority: Option<MessagePriority>Message priority
flush: boolWhether to flush immediately after sending
timeout: Option<Duration>Timeout for the send operation
Trait Implementations§
Source§impl Clone for SendOptions
impl Clone for SendOptions
Source§fn clone(&self) -> SendOptions
fn clone(&self) -> SendOptions
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 Debug for SendOptions
impl Debug for SendOptions
Source§impl Default for SendOptions
impl Default for SendOptions
Source§fn default() -> SendOptions
fn default() -> SendOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SendOptions
impl RefUnwindSafe for SendOptions
impl Send for SendOptions
impl Sync for SendOptions
impl Unpin for SendOptions
impl UnsafeUnpin for SendOptions
impl UnwindSafe for SendOptions
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