floaout/
lib.rs

1#![doc = include_str!("../README.md")]
2
3use std::io::{ErrorKind, Read, Result, Write};
4
5pub use crate::colors::{Rgb, Rgba};
6pub use crate::coord::{BubFnsCoord, Coord};
7pub use crate::crc::CRC_32K_4_2;
8pub use crate::lpcm::{Frame, LpcmKind, Sample};
9pub use crate::space::{OaoSpace, OaoSpaces};
10
11pub mod bub;
12pub mod colors;
13pub mod coord;
14pub mod crc;
15pub mod io;
16pub mod lpcm;
17pub mod oao;
18pub mod space;
19pub mod utils;
20pub mod wav;
21
22/// Metadata
23pub trait Metadata {}
24
25/// FrameIOKind
26pub enum FrameIOKind<F32LE, F64LE> {
27    F32LE(F32LE),
28    F64LE(F64LE),
29}
30
31impl<F32LE, F64LE> FrameIOKind<F32LE, F64LE> {
32    pub fn into_f32_le(self) -> Result<F32LE> {
33        match self {
34            Self::F32LE(r) => Ok(r),
35            Self::F64LE(_) => Err(utils::expected_and_found_error(
36                ErrorKind::Other,
37                LpcmKind::F32LE,
38                LpcmKind::F64LE,
39            )),
40        }
41    }
42
43    pub fn into_f64_le(self) -> Result<F64LE> {
44        match self {
45            Self::F32LE(_) => Err(utils::expected_and_found_error(
46                ErrorKind::Other,
47                LpcmKind::F64LE,
48                LpcmKind::F32LE,
49            )),
50            Self::F64LE(r) => Ok(r),
51        }
52    }
53}
54
55/// Frame Reader
56pub trait FrameReader<R: Read, S: Sample>: Iterator<Item = Result<Frame<S>>> {
57    fn get_ref(&self) -> &R;
58    fn get_mut(&mut self) -> &mut R;
59    fn into_inner(self) -> R;
60    // From Metadata
61    fn frames(&self) -> u64;
62    fn samples_per_sec(&self) -> f64;
63
64    /// Number of channels
65    fn number_of_channels(&self) -> u32;
66}
67/// Reader
68pub trait Reader {}
69
70/// Frame Writer
71pub trait FrameWriter<W: Write> {
72    fn flush(&mut self) -> Result<()>;
73    fn get_ref(&self) -> &W;
74    fn get_mut(&mut self) -> &mut W;
75    fn into_inner(self) -> W;
76}
77/// Writer
78pub trait Writer {}