pub struct TryDecimator<P>(pub P);Expand description
Checked variant of Decimator.
This preserves the same chunked interface but reports contract violations instead of panicking.
§Examples
use dsp_process::{DecimatorError, FnSplitProcess, SplitProcess, TryDecimator};
let proc = TryDecimator(FnSplitProcess(|state: &mut bool, x: i32| {
let y = if *state { Some(x) } else { None };
*state = !*state;
y
}));
let mut tick = false;
assert_eq!(proc.process(&mut tick, [1, 2]), Ok(2));
let never = TryDecimator(FnSplitProcess(|_: &mut (), _: i32| None::<i32>));
let mut state = ();
assert_eq!(
never.process(&mut state, [1, 2]),
Err(DecimatorError::NoTick)
);Tuple Fields§
§0: PTrait Implementations§
Source§impl<P: Clone> Clone for TryDecimator<P>
impl<P: Clone> Clone for TryDecimator<P>
Source§fn clone(&self) -> TryDecimator<P>
fn clone(&self) -> TryDecimator<P>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<P: Debug> Debug for TryDecimator<P>
impl<P: Debug> Debug for TryDecimator<P>
Source§impl<P: Default> Default for TryDecimator<P>
impl<P: Default> Default for TryDecimator<P>
Source§fn default() -> TryDecimator<P>
fn default() -> TryDecimator<P>
Returns the “default value” for a type. Read more
Source§impl<X: Copy, Y, C: SplitProcess<X, Option<Y>, S>, S, const N: usize> SplitProcess<[X; N], Result<Y, DecimatorError>, S> for TryDecimator<C>
impl<X: Copy, Y, C: SplitProcess<X, Option<Y>, S>, S, const N: usize> SplitProcess<[X; N], Result<Y, DecimatorError>, S> for TryDecimator<C>
Auto Trait Implementations§
impl<P> Freeze for TryDecimator<P>where
P: Freeze,
impl<P> RefUnwindSafe for TryDecimator<P>where
P: RefUnwindSafe,
impl<P> Send for TryDecimator<P>where
P: Send,
impl<P> Sync for TryDecimator<P>where
P: Sync,
impl<P> Unpin for TryDecimator<P>where
P: Unpin,
impl<P> UnsafeUnpin for TryDecimator<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for TryDecimator<P>where
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'a, 'b, X, Y, S, T, const L: usize> SplitViewProcess<View<'a, X, FrameMajor, L>, ViewMut<'b, Y, FrameMajor, L>, S> for T
impl<'a, 'b, X, Y, S, T, const L: usize> SplitViewProcess<View<'a, X, FrameMajor, L>, ViewMut<'b, Y, FrameMajor, L>, S> for T
Source§fn process_view(
&self,
state: &mut S,
x: View<'a, X, FrameMajor, L>,
y: ViewMut<'b, Y, FrameMajor, L>,
)
fn process_view( &self, state: &mut S, x: View<'a, X, FrameMajor, L>, y: ViewMut<'b, Y, FrameMajor, L>, )
Process one typed input view into one typed output view.