[−][src]Struct ichen_openprotocol::MessageOptions
Common options of an Open Protocol message.
Methods
impl<'a> MessageOptions<'a>
[src]
pub fn id(&self) -> Option<&str>
[src]
Get the message ID, if any.
Examples
let mut opt = MessageOptions::new(); opt.set_id("hello")?; assert_eq!(Some("hello"), opt.id()); opt.clear_id(); assert_eq!(None, opt.id());
pub fn sequence(&self) -> u64
[src]
Examples
let opt1 = MessageOptions::new(); assert_eq!(1, opt1.sequence()); let opt2 = MessageOptions::new(); assert_eq!(2, opt2.sequence()); // `sequence` auto-increments.
pub fn priority(&self) -> i32
[src]
Get the message priority.
Examples
let opt1 = MessageOptions::new_with_priority(100); assert_eq!(100, opt1.priority()); let opt2 = MessageOptions::new_with_priority(-42); assert_eq!(-42, opt2.priority());
pub fn set_id(&mut self, id: &'a str) -> Result<(), String>
[src]
Set the message ID.
Errors
Returns Err(String)
if the ID string is empty or all-whitespace.
Error Examples
let mut opt = MessageOptions::new(); assert_eq!(Err("invalid value: a non-empty, non-whitespace, all-ASCII string required".into()), opt.set_id(""));
Examples
let mut opt = MessageOptions::new(); opt.set_id("hello")?; assert_eq!(Some("hello"), opt.id()); opt.clear_id(); assert_eq!(None, opt.id());
pub fn clear_id(&mut self)
[src]
Set the message ID to None
.
Examples
let mut opt = MessageOptions::new(); opt.set_id("hello")?; assert_eq!(Some("hello"), opt.id()); opt.clear_id(); assert_eq!(None, opt.id());
pub fn new() -> Self
[src]
Create a MessageOptions
with default values (for example, the sequence
field
auto-increments).
Examples
let opt1 = MessageOptions::new(); assert_eq!(1, opt1.sequence()); assert_eq!(0, opt1.priority()); let opt2 = MessageOptions::new(); assert_eq!(2, opt2.sequence()); // `sequence` auto-increments. assert_eq!(0, opt2.priority());
pub fn new_with_priority(priority: i32) -> Self
[src]
Create a MessageOptions
with a particular priority
but otherwise
default values (for example, the sequence
field auto-increments).
Examples
let opt1 = MessageOptions::new_with_priority(100); assert_eq!(1, opt1.sequence()); assert_eq!(100, opt1.priority()); let opt2 = MessageOptions::new_with_priority(-42); assert_eq!(2, opt2.sequence()); // `sequence` auto-increments. assert_eq!(-42, opt2.priority());
Trait Implementations
impl<'a> Clone for MessageOptions<'a>
[src]
fn clone(&self) -> MessageOptions<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a> Debug for MessageOptions<'a>
[src]
impl<'_> Default for MessageOptions<'_>
[src]
fn default() -> Self
[src]
Default value for MessageOptions
.
The sequence
field is auto-incrementing.
Examples
let opt1: MessageOptions = Default::default(); assert_eq!(1, opt1.sequence()); assert_eq!(0, opt1.priority()); let opt2: MessageOptions = Default::default(); assert_eq!(2, opt2.sequence()); // `sequence` auto-increments. assert_eq!(0, opt2.priority());
impl<'de: 'a, 'a> Deserialize<'de> for MessageOptions<'a>
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<'a> Hash for MessageOptions<'a>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a> Serialize for MessageOptions<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for MessageOptions<'a>
impl<'a> Send for MessageOptions<'a>
impl<'a> Sync for MessageOptions<'a>
impl<'a> Unpin for MessageOptions<'a>
impl<'a> UnwindSafe for MessageOptions<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Typeable for T where
T: Any,
T: Any,