pub trait StaticSchemaMarker {
const UNIQUE_MARKER_TYPE_NAME: &'static str;
const FIELDS: &'static [StaticSchemaMarkerField];
const DESCRIPTION: Option<&'static str> = None;
const LOCATIONS: MarkerLocations = _;
const CHART_LABEL: Option<&'static str> = None;
const TOOLTIP_LABEL: Option<&'static str> = None;
const TABLE_LABEL: Option<&'static str> = None;
const GRAPHS: &'static [StaticSchemaMarkerGraph] = _;
// Required methods
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 trait for markers whose schema is known at compile time. Any type which implements
StaticSchemaMarker
automatically implements the Marker
trait via a blanket impl.
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.
In StaticSchemaMarker
, the schema is returned from a static schema
method.
use fxprof_processed_profile::{
Profile, Marker, MarkerLocations, MarkerFieldFlags, MarkerFieldFormat, StaticSchemaMarkerField,
StaticSchemaMarker, CategoryHandle, StringHandle,
};
/// An example marker type with a name and some text content.
#[derive(Debug, Clone)]
pub struct TextMarker {
pub name: StringHandle,
pub text: StringHandle,
}
impl StaticSchemaMarker for TextMarker {
const UNIQUE_MARKER_TYPE_NAME: &'static str = "Text";
const LOCATIONS: MarkerLocations = MarkerLocations::MARKER_CHART.union(MarkerLocations::MARKER_TABLE);
const CHART_LABEL: Option<&'static str> = Some("{marker.data.text}");
const TABLE_LABEL: Option<&'static str> = Some("{marker.name} - {marker.data.text}");
const FIELDS: &'static [StaticSchemaMarkerField] = &[StaticSchemaMarkerField {
key: "text",
label: "Contents",
format: MarkerFieldFormat::String,
flags: MarkerFieldFlags::SEARCHABLE,
}];
fn name(&self, _profile: &mut Profile) -> StringHandle {
self.name
}
fn category(&self, _profile: &mut Profile) -> CategoryHandle {
CategoryHandle::OTHER
}
fn string_field_value(&self, _field_index: u32) -> StringHandle {
self.text
}
fn number_field_value(&self, _field_index: u32) -> f64 {
unreachable!()
}
}
Required Associated Constants§
Sourceconst UNIQUE_MARKER_TYPE_NAME: &'static str
const UNIQUE_MARKER_TYPE_NAME: &'static str
A unique string name for this marker type. Has to match the
RuntimeSchemaMarkerSchema::type_name
of this type’s schema.
Sourceconst FIELDS: &'static [StaticSchemaMarkerField]
const FIELDS: &'static [StaticSchemaMarkerField]
The marker fields. The values are supplied by each marker, in the marker’s
implementations of the string_field_value
and number_field_value
trait methods.
Provided Associated Constants§
Sourceconst DESCRIPTION: Option<&'static str> = None
const DESCRIPTION: Option<&'static str> = None
An optional description string. Applies to all markers of this type.
Sourceconst LOCATIONS: MarkerLocations = _
const LOCATIONS: MarkerLocations = _
Set of marker display locations.
Sourceconst CHART_LABEL: Option<&'static str> = None
const CHART_LABEL: Option<&'static str> = None
A template string defining the label shown within each marker’s box in the marker chart.
Usable template literals are {marker.name}
and {marker.data.fieldkey}
.
If set to None
, the boxes in the marker chart will be empty.
Sourceconst TOOLTIP_LABEL: Option<&'static str> = None
const TOOLTIP_LABEL: Option<&'static str> = None
A template string defining the label shown in the first row of the marker’s tooltip.
Usable template literals are {marker.name}
and {marker.data.fieldkey}
.
Defaults to {marker.name}
if set to None
.
Sourceconst TABLE_LABEL: Option<&'static str> = None
const TABLE_LABEL: Option<&'static str> = None
A template string defining the label shown within each marker’s box in the marker chart.
Usable template literals are {marker.name}
and {marker.data.fieldkey}
.
Defaults to {marker.name}
if set to None
.
Sourceconst GRAPHS: &'static [StaticSchemaMarkerGraph] = _
const GRAPHS: &'static [StaticSchemaMarkerGraph] = _
Any graph lines / segments created from markers of this type.
If this is non-empty, the Firefox Profiler will create one graph track per marker name, per thread, based on the markers it finds on that thread. The marker name becomes the track’s label.
The elements in the graphs array describe individual graph lines or bar chart segments which are all drawn inside the same track, stacked on top of each other, in the order that they’re listed here, with the first entry becoming the bottom-most graph within the track.
Required Methods§
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
.
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.