looklook 0.5.0

Descriptive signal synthesiser.
// 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 [`Config`] structure.

use crate::config::{Builder, Format};
use crate::mode::{self, Mode};

/// A render configuration.
#[derive(Debug)]
#[derive_const(Clone)]
pub struct Config {
	/// The sampling depth
	pub sample_depth: u32,

	/// The amount of channels.
	pub channel_count: u32,

	/// The frame width.
	pub width: u32,

	/// The frame height.
	pub height: u32,

	/// The total count of frames.
	pub duration: u64,

	/// The frame rate.
	pub frame_rate: u32,

	/// The output format.
	pub format: Format,
}

impl Config {
	/// Constructs a new config from a config builder.
	#[must_use]
	pub const fn from_builder(builder: Builder) -> Self {
		let sample_depth = builder.sample_depth
			.expect("expected sampling depth");

		let channel_count = builder.channel_count
			.expect("expected channel count");

		let width = builder.width
			.expect("expected frame width");

		let height = builder.height
			.expect("expected frame height");

		let duration = builder.duration
			.expect("expected render duration");

		let frame_rate = builder.frame_rate
			.expect("expected frame rate");

		let format = builder.format
			.expect("expected output format");

		Self { sample_depth,channel_count, width, height, duration, frame_rate, format }
	}

	/// Builds a mode from the config.
	///
	/// # Panics
	///
	/// This method will panic if the config is not
	/// suitable for rendering.
	pub const fn build_mode(&self) -> Mode {
		mode::Builder::new()
			.sample_depth(self.sample_depth)
			.channel_count(self.channel_count)
			.width(self.width)
			.height(self.height)
			.duration(self.duration)
			.build()
	}
}