pub struct Packet {
pub payload: PacketPayload,
/* private fields */
}
Expand description
Re-export of wick_packet::Base64Bytes as Bytes.
Fields§
§payload: PacketPayload
Implementations§
Source§impl Packet
impl Packet
Sourcepub const FATAL_ERROR: &'static str = "<error>"
pub const FATAL_ERROR: &'static str = "<error>"
The port name that indicates a component-wide fatal error.
pub const NO_INPUT: &'static str = "<>"
Sourcepub const fn new_raw(
payload: PacketPayload,
wasmrs: Metadata,
metadata: WickMetadata,
) -> Packet
pub const fn new_raw( payload: PacketPayload, wasmrs: Metadata, metadata: WickMetadata, ) -> Packet
Create a new packet for the given port with a raw PacketPayload, wasmRS Metadata, and WickMetadata.
Sourcepub fn new_for_port<T>(port: T, payload: PacketPayload, flags: u8) -> Packet
pub fn new_for_port<T>(port: T, payload: PacketPayload, flags: u8) -> Packet
Create a new packet for the given port with a raw PacketPayload value and given flags.
pub fn no_input() -> Packet
Sourcepub fn component_error<T>(err: T) -> Packet
pub fn component_error<T>(err: T) -> Packet
Create a new fatal error packet for the component.
Sourcepub fn ok<T>(port: T, payload: RawPayload) -> Packet
pub fn ok<T>(port: T, payload: RawPayload) -> Packet
Create a new success packet for the given port with a raw RawPayload value.
Sourcepub fn raw_err<T>(port: T, payload: PacketError) -> Packet
pub fn raw_err<T>(port: T, payload: PacketError) -> Packet
Create a new error packet for the given port with a raw PacketError value.
Sourcepub fn open_bracket<T>(port: T) -> Packet
pub fn open_bracket<T>(port: T) -> Packet
Create a new open bracket packet for the given port.
Sourcepub fn close_bracket<T>(port: T) -> Packet
pub fn close_bracket<T>(port: T) -> Packet
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, T>(port: P, data: T) -> Packet
pub fn encode<P, T>(port: P, data: T) -> Packet
Encode a value into a Packet for the given port.
Sourcepub fn decode<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
pub fn decode<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
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<Packet, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Packet, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<Result<RawPayload, PayloadError>> for Packet
impl From<Result<RawPayload, PayloadError>> for Packet
Source§fn from(p: Result<RawPayload, PayloadError>) -> Packet
fn from(p: Result<RawPayload, PayloadError>) -> Packet
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.