pile-audio refactor
This commit is contained in:
54
crates/pile-audio/src/errors.rs
Normal file
54
crates/pile-audio/src/errors.rs
Normal file
@@ -0,0 +1,54 @@
|
||||
//! FLAC errors
|
||||
use std::string::FromUtf8Error;
|
||||
use thiserror::Error;
|
||||
|
||||
#[expect(missing_docs)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum FlacDecodeError {
|
||||
/// FLAC does not start with 0x66 0x4C 0x61 0x43
|
||||
#[error("flac signature is missing or malformed")]
|
||||
BadMagicBytes,
|
||||
|
||||
/// The first metablock isn't StreamInfo
|
||||
#[error("first metablock isn't streaminfo")]
|
||||
BadFirstBlock,
|
||||
|
||||
/// We got an invalid metadata block type
|
||||
#[error("invalid flac metablock type {0}")]
|
||||
BadMetablockType(u8),
|
||||
|
||||
/// We encountered an i/o error while processing
|
||||
#[error("i/o error")]
|
||||
IoError(#[from] std::io::Error),
|
||||
|
||||
/// We tried to decode a string, but found invalid UTF-8
|
||||
#[error("could not decode string")]
|
||||
FailedStringDecode(#[from] FromUtf8Error),
|
||||
|
||||
/// We tried to read a block, but it was out of spec.
|
||||
#[error("malformed flac block")]
|
||||
MalformedBlock,
|
||||
|
||||
/// We could not parse a vorbis comment string
|
||||
#[error("malformed vorbis comment string: {0:?}")]
|
||||
MalformedCommentString(String),
|
||||
|
||||
/// We could not parse a vorbis comment string
|
||||
#[error("malformed vorbis picture")]
|
||||
MalformedPicture(base64::DecodeError),
|
||||
|
||||
/// We didn't find frame sync bytes where we expected them
|
||||
#[error("bad frame sync bytes")]
|
||||
BadSyncBytes,
|
||||
|
||||
#[error("invalid picture type {0}")]
|
||||
InvalidPictureType(u32),
|
||||
}
|
||||
|
||||
#[expect(missing_docs)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum FlacEncodeError {
|
||||
/// We encountered an i/o error while processing
|
||||
#[error("i/o error")]
|
||||
IoError(#[from] std::io::Error),
|
||||
}
|
||||
Reference in New Issue
Block a user