1use std::error::Error;
4use std::fmt::Display;
5use std::string::FromUtf8Error;
6
7#[derive(Debug, Clone, PartialEq, Eq)]
9pub enum MetadataParseError {
10 InvalidUtf8(FromUtf8Error),
12 Empty(EmptyMetadataError),
14}
15
16impl Display for MetadataParseError {
17 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
18 f.write_str(
19 "Failed to parse icy metadata block as a string. The stream may not be properly \
20 encoded.",
21 )
22 }
23}
24
25impl Error for MetadataParseError {}
26
27#[derive(Debug, Clone, PartialEq, Eq)]
29pub struct EmptyMetadataError(pub String);
30
31impl Display for EmptyMetadataError {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 write!(f, "No valid values found for metadata block {}", self.0)
34 }
35}
36
37impl Error for EmptyMetadataError {}