Struct wick_packet::Packet
source · pub struct Packet {
pub payload: PacketPayload,
/* private fields */
}
Fields§
§payload: PacketPayload
Implementations§
source§impl Packet
impl Packet
sourcepub const FATAL_ERROR: &str = "<error>"
pub const FATAL_ERROR: &str = "<error>"
The port name that indicates a component-wide fatal error.
pub const NO_INPUT: &str = "<>"
sourcepub const fn new_raw(
payload: PacketPayload,
wasmrs: Metadata,
metadata: WickMetadata
) -> Self
pub const fn new_raw( payload: PacketPayload, wasmrs: Metadata, metadata: WickMetadata ) -> Self
Create a new packet for the given port with a raw PacketPayload, wasmRS Metadata, and WickMetadata.
sourcepub fn new_for_port<T: Into<String>>(
port: T,
payload: PacketPayload,
flags: u8
) -> Self
pub fn new_for_port<T: Into<String>>( port: T, payload: PacketPayload, flags: u8 ) -> Self
Create a new packet for the given port with a raw PacketPayload value and given flags.
pub fn no_input() -> Self
sourcepub fn component_error<T: Into<String>>(err: T) -> Self
pub fn component_error<T: Into<String>>(err: T) -> Self
Create a new fatal error packet for the component.
sourcepub fn ok<T: Into<String>>(port: T, payload: RawPayload) -> Self
pub fn ok<T: Into<String>>(port: T, payload: RawPayload) -> Self
Create a new success packet for the given port with a raw RawPayload value.
sourcepub fn raw_err<T: Into<String>>(port: T, payload: PacketError) -> Self
pub fn raw_err<T: Into<String>>(port: T, payload: PacketError) -> Self
Create a new error packet for the given port with a raw PacketError value.
sourcepub fn err<T: Into<String>, E: Into<String>>(port: T, msg: E) -> Self
pub fn err<T: Into<String>, E: Into<String>>(port: T, msg: E) -> Self
Create a new error packet for the given port.
sourcepub fn open_bracket<T: Into<String>>(port: T) -> Self
pub fn open_bracket<T: Into<String>>(port: T) -> Self
Create a new open bracket packet for the given port.
sourcepub fn close_bracket<T: Into<String>>(port: T) -> Self
pub fn close_bracket<T: Into<String>>(port: T) -> Self
Create a close bracket packet for the given port.
sourcepub fn context(&self) -> Option<Base64Bytes>
pub fn context(&self) -> Option<Base64Bytes>
Get the context of a crate::ContextTransport on this packet.
sourcepub fn set_context(&mut self, context: Base64Bytes)
pub fn set_context(&mut self, context: Base64Bytes)
Set the content of a crate::ContextTransport on this packet.
sourcepub fn encode<P: Into<String>, T: Serialize>(port: P, data: T) -> Self
pub fn encode<P: Into<String>, T: Serialize>(port: P, data: T) -> Self
Encode a value into a Packet for the given port.
sourcepub fn decode<T: DeserializeOwned>(&self) -> Result<T, Error>
pub fn decode<T: DeserializeOwned>(&self) -> Result<T, Error>
Try to deserialize a Packet into the target type.
sourcepub fn to_type_wrapper(self, ty: Type) -> Result<TypeWrapper, Error>
pub fn to_type_wrapper(self, ty: Type) -> Result<TypeWrapper, Error>
Partially decode a Packet and wrap it into a TypeWrapper.
sourcepub fn decode_value(&self) -> Result<Value, Error>
pub fn decode_value(&self) -> Result<Value, Error>
Decode a Packet into a serde_json::Value.
sourcepub const fn payload(&self) -> &PacketPayload
pub const fn payload(&self) -> &PacketPayload
Get the inner payload of this packet.
sourcepub fn unwrap_payload(self) -> Option<Base64Bytes>
pub fn unwrap_payload(self) -> Option<Base64Bytes>
Returns the payload, panicking if it is an error.
sourcepub fn unwrap_err(self) -> PacketError
pub fn unwrap_err(self) -> PacketError
Returns the error, panicking if the packet was a success packet.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Packet
impl<'de> Deserialize<'de> for Packet
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>,
source§impl From<Packet> for Result<RawPayload, PayloadError>
impl From<Packet> for Result<RawPayload, PayloadError>
source§impl From<Result<RawPayload, PayloadError>> for Packet
impl From<Result<RawPayload, PayloadError>> for Packet
source§fn from(p: Result<RawPayload, PayloadError>) -> Self
fn from(p: Result<RawPayload, PayloadError>) -> Self
source§impl PacketExt for Packet
impl PacketExt for Packet
source§fn is_fatal_error(&self) -> bool
fn is_fatal_error(&self) -> bool
true
if this is a fatal, component wide error packet.