#![forbid(unsafe_code)]
use crate::include::common::bitdepth::BitDepth;
use std::ops::Deref;
use std::ops::DerefMut;
pub trait Strided {
fn stride(&self) -> isize;
fn pixel_stride<BD: BitDepth>(&self) -> isize {
BD::pxstride(self.stride())
}
}
impl<S: Strided> Strided for &S {
fn stride(&self) -> isize {
(*self).stride()
}
}
#[derive(Clone, Copy)]
pub struct WithStride<T> {
pub buf: T,
pub stride: isize,
}
impl<T> Strided for WithStride<T> {
fn stride(&self) -> isize {
self.stride
}
}
impl<T> Deref for WithStride<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.buf
}
}
impl<T> DerefMut for WithStride<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.buf
}
}