geng_rodio/source/
empty.rs1use std::marker::PhantomData;
2use std::time::Duration;
3
4use crate::{Sample, Source};
5
6#[derive(Debug, Copy, Clone)]
8pub struct Empty<S>(PhantomData<S>);
9
10impl<S> Default for Empty<S> {
11 #[inline]
12 fn default() -> Self {
13 Self::new()
14 }
15}
16
17impl<S> Empty<S> {
18 #[inline]
19 pub fn new() -> Empty<S> {
20 Empty(PhantomData)
21 }
22}
23
24impl<S> Iterator for Empty<S> {
25 type Item = S;
26
27 #[inline]
28 fn next(&mut self) -> Option<S> {
29 None
30 }
31}
32
33impl<S> Source for Empty<S>
34where
35 S: Sample,
36{
37 #[inline]
38 fn current_frame_len(&self) -> Option<usize> {
39 None
40 }
41
42 #[inline]
43 fn channels(&self) -> u16 {
44 1
45 }
46
47 #[inline]
48 fn sample_rate(&self) -> u32 {
49 48000
50 }
51
52 #[inline]
53 fn total_duration(&self) -> Option<Duration> {
54 Some(Duration::new(0, 0))
55 }
56}