Record

Struct Record 

Source
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>

Source

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.

Source

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.

Source

pub fn len(&self) -> usize

Get the total length, in bytes, of this record.

Source

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.

Source

pub fn to_vec(&self) -> Vec<u8>

Copy the bytes of this record to an owned Vec.

Source

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.

Source

pub fn parse_record(&self) -> ParseResult<Record<'_>>

Parse the data in this record to a data::Record enum.

Trait Implementations§

Source§

impl<'s> Drop for Record<'s>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'s> Send for Record<'s>

Source§

impl<'s> Sync for Record<'s>

Auto Trait Implementations§

§

impl<'a> Freeze for Record<'a>

§

impl<'a> RefUnwindSafe for Record<'a>

§

impl<'a> Unpin for Record<'a>

§

impl<'a> UnwindSafe for Record<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> EventData for T
where T: Send + Sync,