pub struct Opaque { /* private fields */ }Expand description
An opaque payload.
Opaque payloads provide an escape hatch to carry arbitrarily shaped, telemetry-adjacent data across a topology. They
follow the common “Any” pattern from Protocol Buffers, where an encoded value is carried as raw bytes alongside
the qualified name of the data type, which allows callers to do lightweight filtering of events by type name before
attempting to fallibly decode the raw bytes into the concrete type identified by the type name field.
Implementations§
Source§impl Opaque
impl Opaque
Sourcepub fn new(type_name: impl Into<MetaString>, data: Bytes) -> Self
pub fn new(type_name: impl Into<MetaString>, data: Bytes) -> Self
Creates a new Opaque from the given type name and encoded data.
Sourcepub fn encode<T: OpaqueType>(value: &T) -> Self
pub fn encode<T: OpaqueType>(value: &T) -> Self
Creates a new Opaque by encoding the given value.
Sourcepub fn is<T: OpaqueType>(&self) -> bool
pub fn is<T: OpaqueType>(&self) -> bool
Returns true if the type name is the type name of T.
Sourcepub fn try_decode<T: OpaqueType>(&self) -> Result<Option<T>, GenericError>
pub fn try_decode<T: OpaqueType>(&self) -> Result<Option<T>, GenericError>
Decodes the data as a value of type T, if the type name is the type name of T.
If the type name isn’t the type name of T, Ok(None) is returned.
§Errors
If the type name matches, but the data isn’t a valid encoding of T, an error is returned.
Trait Implementations§
impl StructuralPartialEq for Opaque
Auto Trait Implementations§
impl !Freeze for Opaque
impl RefUnwindSafe for Opaque
impl Send for Opaque
impl Sync for Opaque
impl Unpin for Opaque
impl UnsafeUnpin for Opaque
impl UnwindSafe for Opaque
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Track for T
impl<T> Track for T
Source§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self> ⓘ
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self> ⓘ
Tracked wrapper. Read more