[][src]Struct ichen_openprotocol::MessageOptions

pub struct MessageOptions<'a> { /* fields omitted */ }

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]

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]

impl<'a> Hash for MessageOptions<'a>[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Typeable for T where
    T: Any