Trait Repr

Source
pub trait Repr<T>:
    Send
    + Sync
    + 'static
where Self: Sized,
{ // Required methods fn from(v: T) -> Self; fn try_into(self) -> Result<T, Self>; fn can_into(&self) -> bool; }
Expand description

Define for the wire representation, so that the raw messages can be lifted into it, and later the representation can be cast back into the expected types.

Similar to From<T> for R plus TryInto<T> for R. Unfortunately the built-in implementations lead to conflicts for DynMessage.

use async_session_types::*;

let repr: DynMessage = Repr::from(123u8);
let msg: u8 = Repr::try_into(repr).unwrap();

Required Methods§

Source

fn from(v: T) -> Self

Convert a raw type to the common representation.

Source

fn try_into(self) -> Result<T, Self>

Try to convert the representation back into one of the raw message types.

Source

fn can_into(&self) -> bool

Check whether the representation can be turned into this raw type, without consuming.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: 'static + Send + Sync> Repr<T> for DynMessage

We can turn anything into a DynMessage.