#![doc(
html_favicon_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/76/Transgender_Pride_flag_square.svg/500px-Transgender_Pride_flag_square.svg.png",
html_logo_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/76/Transgender_Pride_flag_square.svg/500px-Transgender_Pride_flag_square.svg.png"
)]
#[macro_use]
pub mod num;
pub mod ascii_str;
pub mod bit_io;
pub mod bits;
pub mod decode;
pub mod encode;
pub mod frame;
pub mod metadata;
use std::io::Seek;
use crate::bit_io::{BitRead, BitWrite, BitWriter};
pub use decode::Flac;
pub const MAGIC: [u8; 4] = *b"fLaC";
pub trait Decode<Opt = ()>: Sized {
type Error;
fn decode<R: BitRead + Seek>(reader: &mut R, _opt: Opt) -> Result<Self, Self::Error>;
#[inline]
fn decode_bytes(bytes: &[u8], opt: Opt) -> Result<Self, Self::Error> {
let mut reader = bit_io::BitReader::new(std::io::Cursor::new(bytes));
Self::decode(&mut reader, opt)
}
}
pub trait Encode<Opt = ()> {
type Error;
fn encode<W: BitWrite>(&self, writer: &mut W, _opt: Opt) -> Result<(), Self::Error>;
#[inline]
fn encode_bytes(&self, opt: Opt) -> Result<Vec<u8>, Self::Error> {
let mut writer = BitWriter::new(std::io::Cursor::new(Vec::new()));
self.encode(&mut writer, opt)?;
Ok(writer.into_inner().into_inner())
}
}