Struct win_etw_provider::EventDataDescriptor
source · #[repr(C)]pub struct EventDataDescriptor<'a> { /* private fields */ }
Expand description
Contains a reference to the data for an event field. The type of the data is not specified in
this structure; instead, the type of the data is stored in the event’s metadata.
(See win_etw_metadata::InFlag
.)
The data that this type points to must have a well-defined (stable) byte representation. For
example, u32
has a well-defined byte representation, as long as there is agreement about
whether the value is stored in big-endian or little-endian order. Similarly, [u8]
and
[u32]
have well-defined byte representations. However, types such as [bool]
do not have a
stable byte representation, and so EventDataDescriptor
cannot point to &[bool]
.
This type provides implementations of From
that can be used to point to event data.
All of the EventDataDescriptor::From
implementations for types require that the types have a
stable, guaranteed byte representation, and that is legal (meaningful) to read that byte
representation.
This type is equivalent to the Win32 structure EVENT_DATA_DESCRIPTOR
, and its representation
is guaranteed to be equivalent.
Implementation warning!
This code is responsible for ensuring memory safety. Even though it contains only simple
primitives, these primitives are actually native pointers and pointer bounds. This data
structure is passed to the ETW implementation, which dereferences those pointers. The Rust
type checker cannot “see” these dereferences, since they occur in non-Rust code, so the borrow
checker does not know that EventDataDescriptor
deals with memory safety. This is why the
phantom_ref
field exists, and it is crucial that this code be used and encapsulated
correctly.
For type safety to be conserved, the following invariants must be maintained:
-
The
'a
lifetime parameter ofEventDataDescriptor<'a>
must be correctly associated with the lifetime of any reference that is used to construct an instance ofEventDataDescriptor
. -
The fields of
EventDataDescriptor
must remain private. Arbitrary user code cannot be permitted to construct instances ofEventDataDescriptor
with arbitrary values for these fields. -
EventDataDescriptor
should only be used to pass to ETW functions.
Implementations§
source§impl EventDataDescriptor<'static>
impl EventDataDescriptor<'static>
source§impl<'a> EventDataDescriptor<'a>
impl<'a> EventDataDescriptor<'a>
sourcepub fn for_provider_metadata(s: &'a [u8]) -> Self
pub fn for_provider_metadata(s: &'a [u8]) -> Self
Creates an EventDataDescriptor
for provider metadata.
sourcepub fn for_event_metadata(s: &'a [u8]) -> Self
pub fn for_event_metadata(s: &'a [u8]) -> Self
Creates an EventDataDescriptor
for the metadata that describes a single event.
Trait Implementations§
source§impl<'a> Clone for EventDataDescriptor<'a>
impl<'a> Clone for EventDataDescriptor<'a>
source§fn clone(&self) -> EventDataDescriptor<'a>
fn clone(&self) -> EventDataDescriptor<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more