pub struct Record<'a> { /* private fields */ }Expand description
A view into a Sampler’s ring buffer for a single kernel event record.
When dropped, this type will advance the tail pointer in the ringbuffer of
the Sampler that it references. To avoid this, you can use
std::mem::forget so the next call to Sampler::next_record will
return the same record again.
Implementations§
Source§impl<'s> Record<'s>
impl<'s> Record<'s>
Sourcepub fn ty(&self) -> u32
pub fn ty(&self) -> u32
Access the type field of the kernel record header.
This indicates the type of the record emitted by the kernel.
Sourcepub fn misc(&self) -> u16
pub fn misc(&self) -> u16
Access the misc field of the kernel record header.
This contains a set of flags that carry some additional metadata on the record being emitted by the kernel.
Sourcepub fn data(&self) -> &[&[u8]]
pub fn data(&self) -> &[&[u8]]
Access the bytes of this record.
Since the underlying buffer is a ring buffer the bytes of the record may end up wrapping around the end of the buffer. That gets exposed here as data returning either one or two byte slices. If there is no wrap-around then one slice will be returned here, otherwise, two will be returned.
Sourcepub fn to_contiguous(&self) -> Cow<'_, [u8]>
pub fn to_contiguous(&self) -> Cow<'_, [u8]>
Get the bytes of this record as a single contiguous slice.
For most records this is effectively free but if the record wraps around the end of the ringbuffer then it will be copied to a vector.
Sourcepub fn parse_record(&self) -> ParseResult<Record<'_>>
pub fn parse_record(&self) -> ParseResult<Record<'_>>
Parse the data in this record to a data::Record enum.