use std::any::Any;
use dyn_clone::DynClone;
use machine_vision_formats::{ImageData, Stride};
pub trait HostTimeData: DynClone + Send + AsAny {
fn host_framenumber(&self) -> usize; fn host_timestamp(&self) -> chrono::DateTime<chrono::Utc>; }
dyn_clone::clone_trait_object!(HostTimeData);
pub trait AsAny {
fn as_any(&self) -> &dyn Any;
}
impl<T: Any> AsAny for T {
fn as_any(&self) -> &dyn Any {
self
}
}
pub trait ExtraTimeData {
fn extra(&self) -> &dyn HostTimeData;
}
pub trait ImageStrideTime<F>: ExtraTimeData + ImageData<F> + Stride {}
impl<S: ExtraTimeData + ImageData<F> + Stride, F> ImageStrideTime<F> for S {}
pub trait FrameTrait<F>: AsImageStrideTime<F> + ImageStrideTime<F> + Into<Vec<u8>> {}
impl<S, F> FrameTrait<F> for S
where
S: AsImageStrideTime<F> + ImageStrideTime<F>,
Vec<u8>: From<S>,
{
}
pub trait AsImageStrideTime<F>: ImageStrideTime<F> {
fn as_image_stride_time(&self) -> &dyn ImageStrideTime<F>;
}
impl<S: ImageStrideTime<F>, F> AsImageStrideTime<F> for S {
fn as_image_stride_time(&self) -> &dyn ImageStrideTime<F> {
self
}
}