Visitor

Trait Visitor 

Source
pub trait Visitor<'a>: Sized {
    type Output;

Show 23 methods // Required method fn visit_unimplemented(self, metadata: RecordMetadata) -> Self::Output; // Provided methods fn visit_mmap( self, record: Mmap<'a>, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_lost(self, record: Lost, metadata: RecordMetadata) -> Self::Output { ... } fn visit_comm( self, record: Comm<'a>, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_exit(self, record: Exit, metadata: RecordMetadata) -> Self::Output { ... } fn visit_throttle( self, record: Throttle, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_unthrottle( self, record: Throttle, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_fork(self, record: Fork, metadata: RecordMetadata) -> Self::Output { ... } fn visit_read(self, record: Read, metadata: RecordMetadata) -> Self::Output { ... } fn visit_sample( self, record: Sample<'a>, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_mmap2( self, record: Mmap2<'a>, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_aux(self, record: Aux, metadata: RecordMetadata) -> Self::Output { ... } fn visit_itrace_start( self, record: ITraceStart, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_lost_samples( self, record: LostSamples, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_switch(self, metadata: RecordMetadata) -> Self::Output { ... } fn visit_switch_cpu_wide( self, record: SwitchCpuWide, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_namespaces( self, record: Namespaces<'a>, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_ksymbol( self, record: KSymbol<'a>, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_bpf_event( self, record: BpfEvent, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_cgroup( self, record: CGroup<'a>, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_text_poke( self, record: TextPoke<'a>, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_aux_output_hw_id( self, record: AuxOutputHwId, metadata: RecordMetadata, ) -> Self::Output { ... } fn visit_unknown( self, data: Cow<'a, [u8]>, metadata: RecordMetadata, ) -> Self::Output { ... }
}
Expand description

A visitor for visiting parsed records.

This is used in combination with Parser::parse_record to parse the record types that you are interested in.

§Implementing a Visitor

To implement a visitor define your output type and implement visit_unimplemented, then, implement whichever visit_* method that is for the event you are interested in:

struct MyVisitor;

impl Visitor<'_> for MyVisitor {
    type Output = ();

    fn visit_unimplemented(self, metadata: RecordMetadata) -> Self::Output {
        println!("got a record with type {}", metadata.ty());
    }
}

Required Associated Types§

Source

type Output

The output type for this visitor.

Required Methods§

Source

fn visit_unimplemented(self, metadata: RecordMetadata) -> Self::Output

Called by the other visit_* methods if they are not implemented.

When implementing a visitor this is this one method that it is required to implement.

Provided Methods§

Source

fn visit_mmap(self, record: Mmap<'a>, metadata: RecordMetadata) -> Self::Output

Visit a Mmap record.

By default, visit_mmap2 forwards to this method.

Source

fn visit_lost(self, record: Lost, metadata: RecordMetadata) -> Self::Output

Visit a Lost record.

Source

fn visit_comm(self, record: Comm<'a>, metadata: RecordMetadata) -> Self::Output

Visit a Comm record.

Source

fn visit_exit(self, record: Exit, metadata: RecordMetadata) -> Self::Output

Visit an Exit record.

Source

fn visit_throttle( self, record: Throttle, metadata: RecordMetadata, ) -> Self::Output

Visit a THROTTLE record.

Source

fn visit_unthrottle( self, record: Throttle, metadata: RecordMetadata, ) -> Self::Output

Visit an UNTHROTTLE record.

Source

fn visit_fork(self, record: Fork, metadata: RecordMetadata) -> Self::Output

Visit a Fork record.

Source

fn visit_read(self, record: Read, metadata: RecordMetadata) -> Self::Output

Visit a Read record.

Source

fn visit_sample( self, record: Sample<'a>, metadata: RecordMetadata, ) -> Self::Output

Visit a Sample record.

Source

fn visit_mmap2( self, record: Mmap2<'a>, metadata: RecordMetadata, ) -> Self::Output

Visit a Mmap2 record.

If not implemented, this forwards to visit_mmap.

Source

fn visit_aux(self, record: Aux, metadata: RecordMetadata) -> Self::Output

Visit an Aux record.

Source

fn visit_itrace_start( self, record: ITraceStart, metadata: RecordMetadata, ) -> Self::Output

Visit an ITraceStart record.

Source

fn visit_lost_samples( self, record: LostSamples, metadata: RecordMetadata, ) -> Self::Output

Visit a LostSamples record.

Source

fn visit_switch(self, metadata: RecordMetadata) -> Self::Output

Visit a SWITCH record.

Source

fn visit_switch_cpu_wide( self, record: SwitchCpuWide, metadata: RecordMetadata, ) -> Self::Output

Visit a SwitchCpuWide record.

Source

fn visit_namespaces( self, record: Namespaces<'a>, metadata: RecordMetadata, ) -> Self::Output

Visit a Namespaces record.

Source

fn visit_ksymbol( self, record: KSymbol<'a>, metadata: RecordMetadata, ) -> Self::Output

Visit a KSymbol record.

Source

fn visit_bpf_event( self, record: BpfEvent, metadata: RecordMetadata, ) -> Self::Output

Visit a BpfEvent record.

Source

fn visit_cgroup( self, record: CGroup<'a>, metadata: RecordMetadata, ) -> Self::Output

Visit a CGroup record.

Source

fn visit_text_poke( self, record: TextPoke<'a>, metadata: RecordMetadata, ) -> Self::Output

Visit a TextPoke record.

Source

fn visit_aux_output_hw_id( self, record: AuxOutputHwId, metadata: RecordMetadata, ) -> Self::Output

Visit a AuxOutputHwId record.

Source

fn visit_unknown( self, data: Cow<'a, [u8]>, metadata: RecordMetadata, ) -> Self::Output

Visit a record not supported by this library.

Note that support for new record types may be added in new minor versions of perf-event-data. This visitor method is provided as a backstop so that users can still choose to handle these should they need it.

If you find yourself using this for a record type emitted by perf_event_open please create an issue or submit a PR to add the record to perf-event-data itself.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§