// Copyright 2026 Gabriel Bjørnager Jensen.
//
// This file is part of LOOKLOOK.
//
// LOOKLOOK is free software: you can redistribute
// it and/or modify it under the terms of the GNU
// Affero General Public License as published by
// the Free Software Foundation, either version 3
// of the License, or (at your option) any later
// version.
//
// LOOKLOOK is distributed in the hope that it will
// be useful, but WITHOUT ANY WARRANTY; without
// even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Affero General Public License for more details.
//
// You should have received a copy of the GNU Af-
// fero General Public License along with LOOKLOOK.
// If not, see <https://www.gnu.org/licenses/>.

//! The [`AudioFormat`] type.

use std::fmt::{self, Display, Formatter};
use std::path::Path;

/// An audio format.
#[non_exhaustive]
#[derive(Copy, Debug)]
#[derive_const(Clone, Default, Eq, PartialEq)]
pub enum AudioFormat {
	/// The [Waveform Audio File AudioFormat](WAVE).
	///
	/// [WAVE]: <https://en.wikipedia.org/wiki/WAV>
	///
	/// File extension: `wav`
	#[default]
	Wave,
}

impl AudioFormat {
	/// Retrieves an identifier for the format.
	#[inline]
	#[must_use]
	pub const fn as_str(self) -> &'static str {
		match self {
			Self::Wave => "wave",
		}
	}

	/// Retrieves the file extension for the format.
	#[inline]
	#[must_use]
	pub fn file_extension(self) -> &'static Path {
		match self {
			Self::Wave => Path::new("wav"),
		}
	}
}

impl Display for AudioFormat {
	fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
		f.write_str(self.as_str())
	}
}
