pub struct Payload {
pub encoding: String,
pub type_hint: Option<String>,
pub data: Vec<u8>,
}Expand description
One payload, as it arrived.
Fields§
§encoding: Stringmetadata["encoding"], e.g. json/plain. Absent on a malformed payload, which is
treated as opaque rather than guessed at.
type_hint: Option<String>metadata["type"], when the producer set one. Search attributes set Keyword; most
SDK payloads set nothing.
data: Vec<u8>Implementations§
Source§impl Payload
impl Payload
pub fn new(encoding: impl Into<String>, data: Vec<u8>) -> Self
Sourcepub fn needs_codec(&self) -> bool
pub fn needs_codec(&self) -> bool
Whether reading this needs a round trip to the user’s codec server.
Any encoding outside Self::NOT_CODEC, not just Temporal’s sample
binary/encrypted. A codec names its own output and real ones do: LORA’s writes
binary/aes_comp, Temporal’s own compression sample writes binary/deflate.
Matching one sample’s name means never calling the codec for the others, which is
indistinguishable from a codec server that is not working.
The cost of being wrong is asymmetric. Offering a custom converter’s output to a codec earns one error; refusing to offer a codec’s output leaves the value unread with nothing on screen to explain why.
An empty encoding is excluded: that is a malformed payload, not ciphertext.
Sourcepub fn render(&self) -> Rendered
pub fn render(&self) -> Rendered
How to show it.
The encodings are Temporal’s own. Anything unrecognised is opaque rather than optimistically decoded as UTF-8: a payload from a custom converter can be arbitrary bytes, and printing those into a terminal is how you end up with a corrupted screen.