Config

Struct Config 

Source
pub struct Config {
    pub mappings: Vec<Mapping>,
    pub overrides: Vec<Override>,
}
Expand description

Configuration for timetable formatting and room mappings.

Loaded from a TOML file containing room-to-department mappings and optional per-lesson overrides.

Fields§

§mappings: Vec<Mapping>

Room-to-department mapping rules

§overrides: Vec<Override>

Per-week/day/period lesson overrides

Implementations§

Source§

impl Config

Source

pub fn load(path: &Path) -> Result<Self, ConfigError>

Load configuration from a TOML file.

§Arguments
  • path - Path to the config.toml file
§Returns

A parsed Config structure.

§Errors

Returns ConfigError if:

  • The file cannot be read
  • The TOML syntax is invalid
  • Required fields are missing
§Example
use timetable_core::config::Config;
use std::path::Path;

let config = Config::load(Path::new("config.toml"))?;
println!("Loaded {} room mappings", config.mappings.len());
Source

pub fn get_style_for_room(&self, room_code: &str) -> Option<&Mapping>

Find the mapping for a given room code.

Returns the mapping with the longest matching prefix. If both ‘MA’ and ‘MA1’ are configured, room ‘MA10’ matches ‘MA1’ (3 chars) over ‘MA’ (2 chars), regardless of configuration order.

§Arguments
  • room_code - Room code to look up (e.g., “MA3”, “SC8”)
§Returns

The matching Mapping, or None if no prefix matches.

§Example
if let Some(mapping) = config.get_style_for_room("MA3") {
    println!("Room MA3 maps to: {}", mapping.map_id);
}
Source

pub fn apply_overrides(&self, weeks: &mut [Week])

Apply configured overrides to parsed weeks.

Modifies lessons in-place based on override rules. Each override specifies a week, day, and period, and can update any combination of subject, room, teacher, or class code.

§Arguments
  • weeks - Mutable slice of week data to modify
§Warnings

Prints warnings to stderr if:

  • Week number is out of range
  • Day or period name is invalid
  • No matching lesson is found for an override
§Example
let config = Config::load(Path::new("config.toml"))?;
let mut weeks = parse_pdf(Path::new("input/timetable.pdf"))?;

config.apply_overrides(&mut weeks);

Trait Implementations§

Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,