[−][src]Struct ichen_openprotocol::MessageOptions
Common options of an Open Protocol message.
Fields
id: Option<&'a str>
Unique ID (if any) of the message for tracking and storage retrieval purposes.
The iChen Server may tag certain messages with a unique tracking key that can be used to retrieve the message from persistent storage later.
sequence: u64
Ever-increasing message sequence number.
This number is usually auto-incremented with each message created, starting from 1.
priority: i32
Priority of the message, smaller number is higher priority. Default = 0.
Methods
impl<'a> MessageOptions<'a>
[src]
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);
pub fn validate(&self) -> Result<'static, ()>
[src]
Validate the data structure.
Errors
Returns Err(
OpenProtocolError::EmptyField
)
if the id
field is set to an empty string
or is all whitespace.
Examples
let opt1 = MessageOptions { id: Some(""), ..Default::default() }; assert_eq!(r#"Err(EmptyField("id"))"#, format!("{:?}", opt1.validate()));
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]
Performs copy-assignment from source
. Read more
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<'a> PartialEq<MessageOptions<'a>> for MessageOptions<'a>
[src]
fn eq(&self, other: &MessageOptions<'a>) -> bool
[src]
fn ne(&self, other: &MessageOptions<'a>) -> bool
[src]
impl<'a> Debug for MessageOptions<'a>
[src]
impl<'a> Serialize for MessageOptions<'a>
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
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>,
Auto Trait Implementations
impl<'a> Sync for MessageOptions<'a>
impl<'a> Send for MessageOptions<'a>
impl<'a> Unpin for MessageOptions<'a>
impl<'a> RefUnwindSafe for MessageOptions<'a>
impl<'a> UnwindSafe for MessageOptions<'a>
Blanket Implementations
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,