Enum distant_protocol::Msg
source · pub enum Msg<T> {
Single(T),
Batch(Vec<T>),
}
Expand description
Represents a wrapper around a message, supporting single and batch payloads.
Variants§
Implementations§
source§impl<T> Msg<T>
impl<T> Msg<T>
sourcepub fn batch<I>(payloads: I) -> Selfwhere
I: IntoIterator<Item = T>,
pub fn batch<I>(payloads: I) -> Selfwhere I: IntoIterator<Item = T>,
Creates a new msg with a batch payload.
sourcepub fn as_single(&self) -> Option<&T>
pub fn as_single(&self) -> Option<&T>
Returns reference to single value if msg is single variant.
sourcepub fn as_mut_single(&mut self) -> Option<&T>
pub fn as_mut_single(&mut self) -> Option<&T>
Returns mutable reference to single value if msg is single variant.
sourcepub fn into_single(self) -> Option<T>
pub fn into_single(self) -> Option<T>
Returns the single value if msg is single variant.
sourcepub fn as_batch(&self) -> Option<&[T]>
pub fn as_batch(&self) -> Option<&[T]>
Returns reference to batch value if msg is batch variant.
sourcepub fn as_mut_batch(&mut self) -> Option<&mut [T]>
pub fn as_mut_batch(&mut self) -> Option<&mut [T]>
Returns mutable reference to batch value if msg is batch variant.
sourcepub fn into_batch(self) -> Option<Vec<T>>
pub fn into_batch(self) -> Option<Vec<T>>
Returns the batch value if msg is batch variant.
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for Msg<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Msg<T>where T: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<T: PartialEq> PartialEq<Msg<T>> for Msg<T>
impl<T: PartialEq> PartialEq<Msg<T>> for Msg<T>
impl<T: Eq> Eq for Msg<T>
impl<T> StructuralEq for Msg<T>
impl<T> StructuralPartialEq for Msg<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Msg<T>where T: RefUnwindSafe,
impl<T> Send for Msg<T>where T: Send,
impl<T> Sync for Msg<T>where T: Sync,
impl<T> Unpin for Msg<T>where T: Unpin,
impl<T> UnwindSafe for Msg<T>where T: UnwindSafe,
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