#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SpanRange {
pub start: u32,
pub end: u32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, PartialOrd, Ord)]
pub struct SpanAttribution {
pub stage: Option<&'static str>,
pub pass: Option<&'static str>,
pub file_id: Option<u32>,
pub block: Option<&'static str>,
pub span: Option<SpanRange>,
}
impl SpanAttribution {
pub const EMPTY: Self = Self {
stage: None,
pass: None,
file_id: None,
block: None,
span: None,
};
#[must_use]
pub const fn new() -> Self {
Self::EMPTY
}
#[must_use]
pub const fn is_empty(&self) -> bool {
self.stage.is_none()
&& self.pass.is_none()
&& self.file_id.is_none()
&& self.block.is_none()
&& self.span.is_none()
}
#[must_use]
pub const fn with_stage(mut self, stage: &'static str) -> Self {
self.stage = Some(stage);
self
}
#[must_use]
pub const fn with_pass(mut self, pass: &'static str) -> Self {
self.pass = Some(pass);
self
}
#[must_use]
pub const fn with_file_id(mut self, file_id: u32) -> Self {
self.file_id = Some(file_id);
self
}
#[must_use]
pub const fn with_block(mut self, block: &'static str) -> Self {
self.block = Some(block);
self
}
#[must_use]
pub const fn with_span(mut self, start: u32, end: u32) -> Self {
self.span = Some(SpanRange { start, end });
self
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub(super) struct AttributedSpanKey {
pub(super) name: &'static str,
pub(super) attribution: SpanAttribution,
}