// 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 [`VideoFormat`] type.

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

/// A video format.
#[non_exhaustive]
#[derive(Copy, Debug)]
#[derive_const(Clone, Default, Eq, PartialEq)]
pub enum VideoFormat {
	/// The [Portable Network Graphics](PNG) format.
	///
	/// [PNG]: <https://en.wikipedia.org/wiki/PNG>
	///
	/// File extension: `png`
	#[default]
	Png,

	/// The [WebP] format.
	///
	/// [WebP]: <https://en.wikipedia.org/wiki/WebP>
	///
	/// File extension: `webp`
	Webp,
}

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

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

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