use crate::{Duration, Time};
use std::sync::Arc;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum BoundaryEdge {
Start,
End,
Cursor,
Duration,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct BoundaryAdjustment {
pub track: Option<usize>,
pub clip: Option<usize>,
pub edge: BoundaryEdge,
pub requested: Time,
pub aligned: Time,
pub frame: i64,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum TimelineWarning {
Boundary(BoundaryAdjustment),
Truncated {
duration: Duration,
content: Duration,
},
}
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct Diagnostics {
warnings: Arc<Vec<TimelineWarning>>,
}
impl Diagnostics {
pub(super) fn new(warnings: Vec<TimelineWarning>) -> Self {
Self {
warnings: Arc::new(warnings),
}
}
pub fn warnings(&self) -> &[TimelineWarning] {
&self.warnings
}
pub fn boundary_adjustments(&self) -> impl Iterator<Item = &BoundaryAdjustment> {
self.warnings.iter().filter_map(|warning| match warning {
TimelineWarning::Boundary(adjustment) => Some(adjustment),
_ => None,
})
}
pub fn is_empty(&self) -> bool {
self.warnings.is_empty()
}
}