pub trait Marker {
// Required methods
fn marker_type(&self, profile: &mut Profile) -> MarkerTypeHandle;
fn name(&self, profile: &mut Profile) -> StringHandle;
fn category(&self, profile: &mut Profile) -> CategoryHandle;
fn string_field_value(&self, field_index: u32) -> StringHandle;
fn number_field_value(&self, field_index: u32) -> f64;
}
Expand description
The marker trait. You’ll likely want to implement StaticSchemaMarker
instead.
Markers have a type, a name, a category, and an arbitrary number of fields.
The fields of a marker type are defined by the marker type’s schema, see RuntimeSchemaMarkerSchema
.
The timestamps are not part of the marker; they are supplied separately to
Profile::add_marker
when a marker is added to the profile.
You can implement this trait manually if the schema of your marker type is only
known at runtime. If the schema is known at compile time, you’ll want to implement
StaticSchemaMarker
instead - there is a blanket impl which implements Marker
for any type that implements StaticSchemaMarker
.
Required Methods§
Sourcefn marker_type(&self, profile: &mut Profile) -> MarkerTypeHandle
fn marker_type(&self, profile: &mut Profile) -> MarkerTypeHandle
The MarkerTypeHandle
of this marker type. Created with Profile::register_marker_type
or
with Profile::static_schema_marker_type
.
Sourcefn name(&self, profile: &mut Profile) -> StringHandle
fn name(&self, profile: &mut Profile) -> StringHandle
The name of this marker, as an interned string handle.
The name is shown as the row label in the marker chart. It can also be
used as {marker.name}
in the various label
template strings in the schema.
Sourcefn category(&self, profile: &mut Profile) -> CategoryHandle
fn category(&self, profile: &mut Profile) -> CategoryHandle
The category of this marker. The marker chart groups marker rows by category.
Sourcefn string_field_value(&self, field_index: u32) -> StringHandle
fn string_field_value(&self, field_index: u32) -> StringHandle
Called for any fields defined in the schema whose format
is
of kind MarkerFieldFormatKind::String
.
field_index
is an index into the schema’s fields
.
You can panic for any unexpected field indexes, for example
using unreachable!()
. You can even panic unconditionally if this
marker type doesn’t have any string fields.
If you do see unexpected calls to this method, make sure you’re not registering
multiple different schemas with the same RuntimeSchemaMarkerSchema::type_name
.
Sourcefn number_field_value(&self, field_index: u32) -> f64
fn number_field_value(&self, field_index: u32) -> f64
Called for any fields defined in the schema whose format
is
of kind MarkerFieldFormatKind::Number
.
field_index
is an index into the schema’s fields
.
You can panic for any unexpected field indexes, for example
using unreachable!()
. You can even panic unconditionally if this
marker type doesn’t have any number fields.
If you do see unexpected calls to this method, make sure you’re not registering
multiple different schemas with the same RuntimeSchemaMarkerSchema::type_name
.