pub enum MessageTransport {
Success(Serialized),
Failure(Failure),
Signal(MessageSignal),
}
Expand description
The MessageTransport is the primary way messages are sent around Wasmflow Networks and Schematics. It is the internal representation for normalized output Packet’s.
Variants
Success(Serialized)
A successful message.
Failure(Failure)
A message stemming from an error somewhere.
Signal(MessageSignal)
An internal signal.
Implementations
sourceimpl MessageTransport
impl MessageTransport
sourcepub fn as_json(&self) -> Value
pub fn as_json(&self) -> Value
Converts a MessageTransport into serde_json::Value representation of a TransportJson
sourcepub fn map_to_json(
raw_result: HashMap<String, MessageTransport>
) -> Map<String, Value>
pub fn map_to_json(
raw_result: HashMap<String, MessageTransport>
) -> Map<String, Value>
Convert a HashMap<String, MessageTransport> into a serde_json::value::Map
sourceimpl MessageTransport
impl MessageTransport
sourcepub fn is_ok(&self) -> bool
pub fn is_ok(&self) -> bool
Returns true
if the Message contains success data destined for a downstream
consumer, false
for Errors, Exceptions, and otherwise.
sourcepub fn is_err(&self) -> bool
pub fn is_err(&self) -> bool
Returns true if the MessageTransport is holding an Error or Exception variant.
sourcepub fn is_signal(&self) -> bool
pub fn is_signal(&self) -> bool
Returns true if the MessageTransport is a MessageTransport::Signal variant.
sourcepub fn to_messagepack(&mut self)
pub fn to_messagepack(&mut self)
Converts the MessageTransport into a messagepack-compatible transport.
sourcepub fn messagepack<T: ?Sized + Serialize>(item: &T) -> Self
pub fn messagepack<T: ?Sized + Serialize>(item: &T) -> Self
Creates a MessageTransport by serializing a passed object with messagepack
sourcepub fn success<T: Serialize>(item: &T) -> Self
pub fn success<T: Serialize>(item: &T) -> Self
Creates a MessageTransport by serializing a passed object into a raw intermediary format
sourcepub fn json<T: Serialize>(item: &T) -> Self
pub fn json<T: Serialize>(item: &T) -> Self
Creates a MessageTransport by serializing a passed object into JSON
sourcepub fn error<T: AsRef<str>>(msg: T) -> Self
pub fn error<T: AsRef<str>>(msg: T) -> Self
Creates a [MessageTransport::Failure(Failure::Error)] with the passed message.
sourcepub fn exception<T: AsRef<str>>(msg: T) -> Self
pub fn exception<T: AsRef<str>>(msg: T) -> Self
Creates a [MessageTransport::Failure(Failure::Exception)] with the passed message.
sourcepub fn deserialize<T: DeserializeOwned>(self) -> Result<T, TransportError>
pub fn deserialize<T: DeserializeOwned>(self) -> Result<T, TransportError>
Try to deserialize a MessageTransport into the target type
Trait Implementations
sourceimpl Clone for MessageTransport
impl Clone for MessageTransport
sourcefn clone(&self) -> MessageTransport
fn clone(&self) -> MessageTransport
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for MessageTransport
impl Debug for MessageTransport
sourceimpl<'de> Deserialize<'de> for MessageTransport
impl<'de> Deserialize<'de> for MessageTransport
sourcefn 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
sourceimpl Display for MessageTransport
impl Display for MessageTransport
sourceimpl From<MessageTransport> for Packet
impl From<MessageTransport> for Packet
sourcefn from(output: MessageTransport) -> Packet
fn from(output: MessageTransport) -> Packet
Converts to this type from the input type.
sourceimpl From<MessageTransport> for Packet
impl From<MessageTransport> for Packet
sourcefn from(output: MessageTransport) -> Packet
fn from(output: MessageTransport) -> Packet
Converts to this type from the input type.
sourceimpl From<Packet> for MessageTransport
impl From<Packet> for MessageTransport
sourcefn from(output: Packet) -> MessageTransport
fn from(output: Packet) -> MessageTransport
Converts to this type from the input type.
sourceimpl From<TransportJson> for MessageTransport
impl From<TransportJson> for MessageTransport
sourcefn from(v: TransportJson) -> Self
fn from(v: TransportJson) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<MessageTransport> for MessageTransport
impl PartialEq<MessageTransport> for MessageTransport
sourcefn eq(&self, other: &MessageTransport) -> bool
fn eq(&self, other: &MessageTransport) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &MessageTransport) -> bool
fn ne(&self, other: &MessageTransport) -> bool
This method tests for !=
.
sourceimpl Serialize for MessageTransport
impl Serialize for MessageTransport
impl StructuralPartialEq for MessageTransport
Auto Trait Implementations
impl RefUnwindSafe for MessageTransport
impl Send for MessageTransport
impl Sync for MessageTransport
impl Unpin for MessageTransport
impl UnwindSafe for MessageTransport
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more