pub struct Payload(/* private fields */);Expand description
Compact binary storage of events created when they are received
see Event::extract for supported ways of using the
data
Implementations§
Source§impl Payload
impl Payload
pub fn from_slice(bytes: &[u8]) -> Self
pub fn as_slice(&self) -> &[u8] ⓘ
pub fn from_json_str(s: &str) -> Result<Payload, String>
Sourcepub fn compact<T: Serialize>(t: &T) -> Result<Payload, Error>
pub fn compact<T: Serialize>(t: &T) -> Result<Payload, Error>
Construct a new Payload from the supplied serializable value.
Sourcepub fn extract<'a, T: Deserialize<'a>>(&'a self) -> Result<T, Error>
pub fn extract<'a, T: Deserialize<'a>>(&'a self) -> Result<T, Error>
Try to lift the desired type from this Payload’s bytes.
Sourcepub fn json_value(&self) -> Value
pub fn json_value(&self) -> Value
Transform into a generic JSON structure that you can then traverse or query.
Sourcepub fn json_string(&self) -> String
pub fn json_string(&self) -> String
Printable representation of this stored object as JSON — the stored Payload bytes are encoded in the CBOR binary format.
Sourcepub fn rough_size(&self) -> usize
pub fn rough_size(&self) -> usize
Rough estimate of the in memory size of the contained opaque value
Sourcepub fn from_json_value(v: Value) -> Result<Payload, String>
pub fn from_json_value(v: Value) -> Result<Payload, String>
Only to be used from tests, since it has bad performance due to a serde bug/issue
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn from_bytes(bytes: &[u8]) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Payload
impl<'de> Deserialize<'de> for Payload
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Payload
impl Ord for Payload
Source§impl PartialOrd for Payload
impl PartialOrd for Payload
impl Eq for Payload
impl StructuralPartialEq for Payload
Auto Trait Implementations§
impl Freeze for Payload
impl !RefUnwindSafe for Payload
impl Send for Payload
impl Sync for Payload
impl Unpin for Payload
impl !UnwindSafe for Payload
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more