use std::marker::PhantomData; use std::time::Duration; use crate::{Sample, Source}; use super::SeekError; /// An empty source. #[derive(Debug, Copy, Clone)] pub struct Empty(PhantomData); impl Default for Empty { #[inline] fn default() -> Self { Self::new() } } impl Empty { #[inline] pub fn new() -> Empty { Empty(PhantomData) } } impl Iterator for Empty { type Item = S; #[inline] fn next(&mut self) -> Option { None } } impl Source for Empty where S: Sample, { #[inline] fn current_frame_len(&self) -> Option { None } #[inline] fn channels(&self) -> u16 { 1 } #[inline] fn sample_rate(&self) -> u32 { 48000 } #[inline] fn total_duration(&self) -> Option { Some(Duration::new(0, 0)) } #[inline] fn try_seek(&mut self, _: Duration) -> Result<(), SeekError> { Err(SeekError::NotSupported { underlying_source: std::any::type_name::(), }) } }