School

Struct School 

Source
pub struct School {
    pub name: String,
    pub degrees: Vec<Degree>,
    pub plans: Vec<Plan>,
    /* private fields */
}
Expand description

Represents an educational institution

Fields§

§name: String

School name

§degrees: Vec<Degree>

Degrees offered by the school

§plans: Vec<Plan>

Curriculum plans offered by the school

Implementations§

Source§

impl School

Source

pub fn new(name: String) -> Self

Create a new school

§Arguments
  • name - School name
Source

pub fn add_course(&mut self, course: Course) -> bool

Add a course to the school

§Arguments
  • course - Course to add
§Returns

true if the course was added, false if a course with that key already exists Add a course to the school (fails if key already exists)

§Arguments
  • course - The course to add
§Returns

true if the course was added, false if a course with the same key already exists

Source

pub fn add_course_with_key(&mut self, key: String, course: Course)

Add a course with a custom key (for handling deduplication)

§Arguments
  • key - Custom key for the course
  • course - The course to add
Source

pub fn get_course(&self, storage_key: &str) -> Option<&Course>

Get a course by its storage key (which may include deduplicated suffixes)

§Arguments
  • storage_key - The key used to store the course in the HashMap
§Returns

A reference to the course, or None if not found

Source

pub fn get_course_by_natural_key(&self, natural_key: &str) -> Option<&Course>

Get a course by its natural key (PREFIX NUMBER) - returns the first match if there are duplicates

§Arguments
  • natural_key - The course key (e.g., “CS2510”)
§Returns

A reference to the course, or None if not found

Source

pub fn get_storage_key(&self, natural_key: &str) -> Option<String>

Get the storage key for a course (which may differ from its natural key due to deduplication)

§Arguments
  • natural_key - The course key (e.g., “CS2510”)
§Returns

The storage key (e.g., “CS2510_2” for a deduplicated course), or None if not found

Source

pub fn get_course_mut(&mut self, key: &str) -> Option<&mut Course>

Get a mutable reference to a course by its key

§Arguments
  • key - Course key (e.g., “CS 2510”)
§Returns

A mutable reference to the course, or None if not found

Source

pub fn courses(&self) -> Vec<&Course>

Get all courses

Source

pub fn courses_with_keys(&self) -> impl Iterator<Item = (&String, &Course)>

Get all courses with their storage keys

§Returns

An iterator over (storage_key, course) pairs

Source

pub fn add_degree(&mut self, degree: Degree)

Add a degree to the school

Source

pub fn get_degree(&self, degree_id: &str) -> Option<&Degree>

Get a degree by its ID

§Arguments
  • degree_id - Degree identifier (e.g., “BS Computer Science”)
§Returns

A reference to the degree, or None if not found

Source

pub fn add_plan(&mut self, plan: Plan)

Add a plan to the school

Source

pub fn get_plans_for_degree(&self, degree_id: &str) -> Vec<&Plan>

Get plans associated with a specific degree

§Arguments
  • degree_id - Degree identifier
§Returns

A vector of references to plans for that degree

Source

pub fn validate_plans(&self) -> Result<(), Vec<String>>

Validate that all courses in all plans exist in the school

§Returns

Ok(()) if all courses exist, Err(Vec<String>) with missing course keys

§Errors

Returns Err with a list of error messages for courses referenced in plans that don’t exist

Source

pub fn validate_course_dependencies(&self) -> Result<(), Vec<String>>

Validate that all prerequisites and corequisites exist

§Returns

Ok(()) if all references are valid, Err(Vec<String>) with invalid references

§Errors

Returns Err with a list of error messages for invalid prerequisite or corequisite references

Source

pub fn build_dag(&self) -> DAG

Build a directed acyclic graph (DAG) of course prerequisites

§Returns

A DAG with all courses and their prerequisite relationships

Trait Implementations§

Source§

impl Clone for School

Source§

fn clone(&self) -> School

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for School

Source§

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

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

impl<'de> Deserialize<'de> for School

Source§

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

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for School

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for School

§

impl RefUnwindSafe for School

§

impl Send for School

§

impl Sync for School

§

impl Unpin for School

§

impl UnwindSafe for School

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

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