### Example Usage: Fetching Certificated Summary (Rust) Source: https://docs.rs/rusaint/latest/src/rusaint/application/course_grades.rs.html?search=std%3A%3Avec Demonstrates how to use the `certificated_summary` function within the `CourseGradesApplication`. It shows the setup of the session and client, followed by calling the function and printing the result. This example requires `tokio_test`, `rusaint`, and specific modules. ```rust # tokio_test::block_on(async { # use std::sync::Arc; # use rusaint::USaintSession; # use rusaint::client::USaintClientBuilder; # use rusaint::application::course_grades::{ model::CourseType, CourseGradesApplication }; # let session = Arc::new(USaintSession::with_password("20212345", "password").await.unwrap()); let mut app = USaintClientBuilder::new().session(session).build_into::().await.unwrap(); let summary = app.certificated_summary(CourseType::Bachelor).await.unwrap(); println!("{:?}", summary); // GradeSummary { ... } # }) ``` -------------------------------- ### Get WebDynpro Application Body (Rust) Source: https://docs.rs/rusaint/latest/rusaint/application/type.USaintClient.html?search= Returns the page document of the WebDynpro application. ```rust pub fn body(&self) -> &Body ``` -------------------------------- ### Get Loaded Lectures (Rust) Source: https://docs.rs/rusaint/latest/rusaint/application/course_schedule/struct.CourseScheduleApplication.html?search=u32+-%3E+bool Retrieves lectures that have been loaded into the current page context. This function should be used after `find_lectures` to get additional details about the searched lectures. It does not perform scrolling and may not work as expected if `find_lectures` returns more than 500 results. ```rust pub fn loaded_lectures( &self, ) -> Result, RusaintError> ``` -------------------------------- ### Get WebDynpro Application Base URL (Rust) Source: https://docs.rs/rusaint/latest/rusaint/application/type.USaintClient.html?search= Returns the base URL of the WebDynpro application. ```rust pub fn base_url(&self) -> &Url ``` -------------------------------- ### Create New USaintClientBuilder (Rust) Source: https://docs.rs/rusaint/latest/rusaint/application/type.USaintClientBuilder.html?search= Provides a constructor function `new()` for `USaintClientBuilder` to create a new instance of the builder. This is the starting point for configuring and building a `USaintClient`. ```rust pub fn new() -> USaintClientBuilder ``` -------------------------------- ### Get Lecture Detail by Code (Rust) Source: https://docs.rs/rusaint/latest/rusaint/application/course_schedule/struct.CourseScheduleApplication.html?search=u32+-%3E+bool Asynchronously fetches detailed information for a specific lecture using its course code. This function should be called after a lecture has been found using `find_lectures`. ```rust pub async fn lecture_detail( &mut self, code: &str, ) -> Result ``` -------------------------------- ### Get StudentAcademicRecord Start Date in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentAcademicRecord.html?search=u32+-%3E+bool Retrieves the start date of the academic record period. This function returns the start date as a string slice. ```rust pub fn start_date(&self) -> &str ``` -------------------------------- ### Initialize Application from Client in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/course_registration_status/struct.CourseRegistrationStatusApplication.html Shows how to instantiate the application using a USaintClient instance, adhering to the USaintApplication trait. ```rust impl USaintApplication for CourseRegistrationStatusApplication { const APP_NAME: &'static str = "ZCMW2110"; fn from_client(client: USaintClient) -> Result; } ``` -------------------------------- ### Initialize and Build USaintClient Source: https://docs.rs/rusaint/latest/rusaint/client/struct.USaintClientBuilder.html?search= Demonstrates how to instantiate a new USaintClientBuilder, configure it with a session, and build the client or a specific application type. ```rust use rusaint::client::USaintClientBuilder; use std::sync::Arc; // Create a new builder let builder = USaintClientBuilder::new(); // Configure with session and build let client = builder.session(session).build("app_name").await?; // Or build a specific application type let app: MyApplication = builder.build_into::().await?; ``` -------------------------------- ### Get Start Date in Rust Source: https://docs.rs/rusaint/latest/src/rusaint/application/student_information/model/religion.rs.html?search= Retrieves the start date as an optional string slice. This method is designed for accessing a date field that might be present or absent. It utilizes `as_deref()` to convert an `Option` to an `Option<&str>`. ```rust pub fn start_date(&self) -> Option<&str> { self.start_date.as_deref() } ``` -------------------------------- ### Initialize and Build USaintClient Source: https://docs.rs/rusaint/latest/rusaint/client/struct.USaintClientBuilder.html?search=u32+-%3E+bool Demonstrates the instantiation of a USaintClientBuilder, configuring it with a session, and building a client or a specific application instance. ```rust pub struct USaintClientBuilder { /* private fields */ } impl USaintClientBuilder { pub fn new() -> USaintClientBuilder; pub fn session(self, session: Arc) -> USaintClientBuilder; pub async fn build(self, name: &str) -> Result; pub async fn build_into(self) -> Result; } ``` -------------------------------- ### Initialize and Build USaintClient Source: https://docs.rs/rusaint/latest/rusaint/application/type.USaintClientBuilder.html Demonstrates how to instantiate a USaintClientBuilder, configure it with a session, and build a client or application instance. Note that this type is deprecated and users should prefer the direct path in the client module. ```rust use rusaint::application::USaintClientBuilder; use std::sync::Arc; async fn example() -> Result<(), Box> { let builder = USaintClientBuilder::new(); let client = builder.build("app_name").await?; Ok(()) } ``` -------------------------------- ### GET /semesters Source: https://docs.rs/rusaint/latest/src/rusaint/application/course_grades.rs.html?search=u32+-%3E+bool Retrieves a list of semesters for a given course type. This is typically used to get a breakdown of academic terms. ```APIDOC ## GET /semesters ### Description Retrieves a list of academic semesters for a specified course type. This endpoint is useful for iterating through different terms to fetch specific grade information per semester. ### Method GET ### Endpoint /semesters ### Parameters #### Query Parameters - **course_type** (CourseType) - Required - The type of courses for which to retrieve the semester list (e.g., Bachelor, Master). ### Request Example ```json { "course_type": "Bachelor" } ``` ### Response #### Success Response (200) - **semesters** (array) - A list of semester identifiers. #### Response Example ```json { "semesters": [ "2023-Fall", "2023-Spring", "2022-Fall" ] } ``` ``` -------------------------------- ### Retrieve Start Date in Rust Source: https://docs.rs/rusaint/latest/src/rusaint/application/student_information/model/religion.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This function returns the start date as an Option<&str>. It accesses the 'start_date' field of the struct and uses 'as_deref()' to convert an Option to an Option<&str>. ```rust /// 신앙시작일을 반환합니다. pub fn start_date(&self) -> Option<&str> { self.start_date.as_deref() } ``` -------------------------------- ### Initialize and Query Student Information in Rust Source: https://docs.rs/rusaint/latest/src/rusaint/application/student_information.rs.html Demonstrates the structure of the StudentInformationApplication struct and the methods used to retrieve student data. It utilizes the USaintClient to perform operations like fetching graduation info, bank account details, and academic records. ```rust impl<'a> StudentInformationApplication { pub fn general(&self) -> Result { Ok(StudentInformation::with_parser(&ElementParser::new( self.body(), ))?) } pub async fn bank_account(&mut self) -> Result { Ok(StudentBankAccount::with_client(&mut self.client).await?) } pub async fn reload(&mut self) -> Result<(), RusaintError> { self.client.reload().await?; Ok(()) } } ``` -------------------------------- ### Setup Lecture Search Parameters (Rust) Source: https://docs.rs/rusaint/latest/src/rusaint/application/course_schedule.rs.html?search= A private helper function to set up the initial parameters for a lecture search. It handles selecting the correct number of rows, the academic year, and the semester before requesting query information based on the `LectureCategory`. It also checks if the resulting table is empty. Dependencies include `ElementParser`, `select_rows`, `select_semester`, `request_query`, `SapTableBodyCommand`, `is_sap_table_empty`, and `ApplicationError`. ```rust async fn setup_lecture_search( &mut self, year: u32, semester: SemesterType, lecture_category: &LectureCategory, ) -> Result<(), RusaintError> { { let parser = ElementParser::new(self.body()); let year_str = format!("{year}"); self.select_rows(&parser, 500).await?; self.select_semester(&parser, &year_str, semester).await?; } lecture_category.request_query(&mut self.client).await?; let parser = ElementParser::new(self.body()); let table = parser.read(SapTableBodyCommand::new(Self::MAIN_TABLE))?; if is_sap_table_empty(&table, &parser) { return Err(ApplicationError::NoLectureResult.into()); } Ok(()) } ``` -------------------------------- ### GET /scholarships Source: https://docs.rs/rusaint/latest/src/rusaint/application/scholarships.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the list of scholarship benefits received by the student. ```APIDOC ## GET /scholarships ### Description Fetches the scholarship history for the authenticated user from the ZCMW7530n application. ### Method GET ### Endpoint /scholarships ### Response #### Success Response (200) - **Vec** (Array) - A list of scholarship records containing details such as name, amount, and date. #### Response Example [ { "name": "Academic Excellence Scholarship", "amount": 1000000, "semester": "2023-1" } ] ``` -------------------------------- ### Retrieve Grade Summaries in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/course_grades/struct.CourseGradesApplication.html Demonstrates how to initialize the CourseGradesApplication and fetch recorded or certificated grade summaries for a student. ```rust let mut app = USaintClientBuilder::new().session(session).build_into::().await.unwrap(); let summary = app.recorded_summary(CourseType::Bachelor).await.unwrap(); println!("{:?}", summary); ``` ```rust let mut app = USaintClientBuilder::new().session(session).build_into::().await.unwrap(); let summary = app.certificated_summary(CourseType::Bachelor).await.unwrap(); println!("{:?}", summary); ``` -------------------------------- ### Get Actual Request URL (Rust) Source: https://docs.rs/rusaint/latest/rusaint/application/type.USaintClient.html?search= Returns the URL that is actually being requested for the application. ```rust pub fn client_url(&self) -> String ``` -------------------------------- ### Implement CourseRegistrationStatusApplication methods Source: https://docs.rs/rusaint/latest/rusaint/application/course_registration_status/struct.CourseRegistrationStatusApplication.html?search=u32+-%3E+bool Key methods for interacting with the application, including retrieving the current semester context, fetching registered lectures, and refreshing the application state. ```rust impl<'app> CourseRegistrationStatusApplication { pub fn get_selected_semester(&self) -> Result<(u32, SemesterType), RusaintError> { ... } pub async fn lectures(&mut self, year: u32, semester: SemesterType) -> Result, RusaintError> { ... } pub async fn reload(&mut self) -> Result<(), RusaintError> { ... } } ``` -------------------------------- ### GET /student/information Source: https://docs.rs/rusaint/latest/src/rusaint/application/student_information.rs.html?search= Retrieves various categories of student information from the ZCMW1001n application. ```APIDOC ## GET /student/information ### Description Retrieves specific student data subsets such as academic records, bank accounts, or family information from the uSaint student information portal. ### Method GET ### Endpoint /student/information/{category} ### Parameters #### Path Parameters - **category** (string) - Required - The specific data category to fetch (e.g., general, graduation, work, family, bank_account, academic_record) ### Request Example GET /student/information/general ### Response #### Success Response (200) - **data** (object) - The requested student information model corresponding to the category. #### Response Example { "student_id": "202312345", "name": "John Doe", "status": "Enrolled" } ``` -------------------------------- ### USaintClientBuilder Initialization Source: https://docs.rs/rusaint/latest/src/rusaint/client.rs.html Provides methods for creating and configuring a `USaintClientBuilder`. The `new` function initializes an empty builder, and the `session` method allows setting an `Arc` for cookie management. The `Default` implementation provides a convenient way to create a new builder. ```rust pub struct USaintClientBuilder { session: Option>, } impl USaintClientBuilder { /// 새로운 빌더를 만듭니다. pub fn new() -> USaintClientBuilder { USaintClientBuilder { session: None } } /// 빌더에 [`USaintSession`]을 추가합니다. pub fn session(mut self, session: Arc) -> USaintClientBuilder { self.session = Some(session); self } } impl Default for USaintClientBuilder { fn default() -> Self { Self::new() } } ``` -------------------------------- ### Interact with PersonalCourseScheduleApplication in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/personal_course_schedule/struct.PersonalCourseScheduleApplication.html?search=u32+-%3E+bool Demonstrates the core methods for the PersonalCourseScheduleApplication, including fetching the current semester, retrieving schedule data, and reloading the application state. ```rust pub struct PersonalCourseScheduleApplication { /* private fields */ } impl PersonalCourseScheduleApplication { pub fn get_selected_semester(&self) -> Result<(u32, SemesterType), RusaintError> { /* ... */ } pub async fn schedule(&mut self, year: u32, semester: SemesterType) -> Result { /* ... */ } pub async fn reload(&mut self) -> Result<(), RusaintError> { /* ... */ } } ``` -------------------------------- ### Get WebDynpro Application Name (Rust) Source: https://docs.rs/rusaint/latest/rusaint/application/type.USaintClient.html?search= Retrieves the name of the WebDynpro application associated with the USaintClient. ```rust pub fn name(&self) -> &str ``` -------------------------------- ### Initialize and Use LectureAssessmentApplication in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/lecture_assessment/struct.LectureAssessmentApplication.html?search=u32+-%3E+bool Demonstrates the structure definition and key methods for the LectureAssessmentApplication, including fetching assessments and refreshing the application state. ```rust pub struct LectureAssessmentApplication { /* private fields */ } impl LectureAssessmentApplication { pub fn get_selected_semester(&self) -> Result<(u32, SemesterType), RusaintError> { ... } pub async fn find_assessments( &mut self, year: u32, semester: SemesterType, lecture_name: Option<&str>, lecture_code: Option, professor_name: Option<&str>, ) -> Result, RusaintError> { ... } pub async fn reload(&mut self) -> Result<(), RusaintError> { ... } } ``` -------------------------------- ### Fetch Semester and Class Grades in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/course_grades/struct.CourseGradesApplication.html?search=u32+-%3E+bool Demonstrates how to retrieve a list of semester grades and specific class grades, including options for fetching detailed class performance. ```rust let mut app = USaintClientBuilder::new().session(session).build_into::().await.unwrap(); let semesters = app.semesters(CourseType::Bachelor).await.unwrap(); println!("{:?}", semesters); ``` ```rust let mut app = USaintClientBuilder::new().session(session).build_into::().await.unwrap(); let classes = app.classes(CourseType::Bachelor, 2022, SemesterType::Two, false).await.unwrap(); println!("{:?}", classes); ``` ```rust let mut app = USaintClientBuilder::new().session(session).build_into::().await.unwrap(); let classes = app.classes(CourseType::Bachelor, 2022, SemesterType::Two, true).await.unwrap(); println!("{:?}", classes); ``` -------------------------------- ### Get Application Name (Rust) Source: https://docs.rs/rusaint/latest/rusaint/application/course_registration_status/struct.CourseRegistrationStatusApplication.html?search=std%3A%3Avec Provides the static application name for the U-Saint WebDynpro application, identified as 'ZCMW2110'. ```rust const APP_NAME: &'static str = "ZCMW2110" ``` -------------------------------- ### Fetch Course Grades using rusaint in Rust Source: https://docs.rs/rusaint/latest/src/rusaint/lib.rs.html?search= This example demonstrates how to use the rusaint library to log in to u-saint and retrieve course grades for a specific academic year and semester. It utilizes `USaintSession` for authentication and `CourseGradesApplication` to fetch the grade data. The example requires environment variables for target year and semester, and assumes a valid password or SSO token is available. ```rust #![warn(missing_docs)] // TODO: Reduce error size and remove this attr #![allow(clippy::result_large_err)] //! _빠르고 간편하며 믿을 수 있는 숭실대학교 u-saint 클라이언트_ //! //! GitHub Badge //! crates.io //! docs.rs //! License //! //! --- //! //! rusaint는 [숭실대학교 u-saint](https://saint.ssu.ac.kr)를 정확하고 빠르게, 간편하게 파싱하고 다양한 환경에서 조작할 수 있는 Rust 기반 비공식 u-saint 클라이언트입니다. //! //! u-saint의 기반인 [SAP Web Dynpro](https://en.wikipedia.org/wiki/Web_Dynpro)에서 사용하는 Lightspeed 라이브러리의 최소 동작을 구현하여 안전하게 u-saint 내부 요소들을 조작하고 파싱할 수 있습니다. //! //! - **JS 런타임 없음** — JS 런타임 없이 자체적으로 요청과 응답에 따른 처리를 수행하므로 HTTPS 요청이 가능한 모든 환경에서 실행 가능합니다. //! - **빠른 속도** — 네이티브 환경으로 컴파일되는 Rust를 이용하고, 휴리스틱 없이 요청이 완료되면 곧바로 실행되어 빠르게 u-saint 를 조작 및 파싱 가능합니다. //! - **멀티플랫폼 지원** — UniFFI를 통한 Kotlin, Swift, Python(예정) 지원 및 Node.js 용 WASM Wrapper(예정)를 제공하여 다양한 플랫폼에서 간편하게 이용할 수 있습니다. //! - **간편한 기능 정의** — rusaint 에서 지원하지 않는 u-saint 애플리케이션에 대한 파싱 및 지원을 제공하는 API를 이용해 간편하게 정의할 수 있습니다. //! ## 예시 //! //! ```no_run //! use rusaint::application::course_grades::{CourseGradesApplication, model::CourseType, model::SemesterGrade}; //! use rusaint::client::USaintClientBuilder; //! use wdpe::element::Element; //! use rusaint::RusaintError; //! use std::sync::Arc; //! use rusaint::USaintSession; //! use futures::executor::block_on; //! //! // 성적 정보를 출력하는 애플리케이션 //! fn main() { //! block_on(print_grades()); //! /* SemesterGrade { year: 2022, semester: "2 학기", attempted_credits: 17.5, earned_credits: 17.5, pf_earned_credits: 0.5, grade_points_average: 4.5, grade_points_sum: 100.0, arithmetic_mean: 100.0, semester_rank: (1, 99), general_rank: (1, 99), academic_probation: false, consult: false, flunked: false } //! */ //! } //! //! async fn print_grades() -> Result<(), RusaintError> { //! // USaintSession::with_token(id: &str, token: &str) 을 이용하여 비밀번호 없이 SSO 토큰으로 로그인 할 수 있음 //! let session = Arc::new(USaintSession::with_password("20211561", "password").await?); //! let mut app = USaintClientBuilder::new().session(session).build_into::().await?; //! let grades: Vec = app.semesters(CourseType::Bachelor).await?; //! for grade in grades { //! println!("{:?}", grade); //! } //! Ok(()) //! } //! ``` #[cfg(feature = "application")] /// rusaint에서 제공하는 기본 u-saint 애플리케이션 pub mod application; #[cfg(feature = "application")] /// u-saint 접속을 위한 기본 클라이언트 pub mod client; #[cfg(feature = "application")] mod error; #[cfg(feature = "application")] pub use error::ApplicationError; #[cfg(feature = "application")] pub use error::RusaintError; #[cfg(feature = "application")] pub use error::SsuSsoError; #[cfg(feature = "application")] mod session; #[cfg(feature = "application")] pub use session::obtain_ssu_sso_token; #[cfg(feature = "application")] pub use session::USaintSession; #[cfg(feature = "application")] /// u-saint 애플리케이션에서 공통으로 사용하는 데이터 pub mod model; pub(crate) mod utils; #[cfg(feature = "uniffi")] uniffi::setup_scaffolding!(); #[cfg(feature = "uniffi")] /// `uniffi` 지원을 위한 모듈 pub mod uniffi_support; #[cfg(test)] #[allow(missing_docs)] pub mod global_test_utils { use crate::{USaintSession, model::SemesterType}; use anyhow::{Error, Result}; use dotenvy::dotenv; use lazy_static::lazy_static; use std::{fs::File, io::BufReader, sync::Arc}; lazy_static! { pub(crate) static ref TARGET_YEAR: u32 = { dotenv().ok(); std::env::var("TARGET_YEAR").unwrap().parse().unwrap() }; pub(crate) static ref TARGET_SEMESTER: SemesterType = { dotenv().ok(); let semester = std::env::var("TARGET_SEMESTER").unwrap(); match semester.to_uppercase().as_str() { "1" | "ONE" => SemesterType::One, "SUMMER" => SemesterType::Summer, "2" | "TWO" => SemesterType::Two, "WINTER" => SemesterType::Winter, _ => panic!("{:?}", Error::msg("Invalid semester")), } }; } pub async fn get_session() -> Result> { let session_file_path = ``` -------------------------------- ### Retrieve Recorded and Certificated Grade Summaries Source: https://docs.rs/rusaint/latest/rusaint/application/course_grades/struct.CourseGradesApplication.html?search= Demonstrates how to fetch overall grade summaries for a student's academic career using recorded_summary and certificated_summary methods. ```rust let mut app = USaintClientBuilder::new().session(session).build_into::().await.unwrap(); let summary = app.recorded_summary(CourseType::Bachelor).await.unwrap(); println!("{:?}", summary); let summary = app.certificated_summary(CourseType::Bachelor).await.unwrap(); println!("{:?}", summary); ``` -------------------------------- ### Get StudentAcademicRecord Reason in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentAcademicRecord.html?search=u32+-%3E+bool Retrieves the reason for the academic record entry. This function returns the reason as a string slice. ```rust pub fn reason(&self) -> &str ``` -------------------------------- ### Retrieve and Print Course Grades in Rust Source: https://docs.rs/rusaint/latest/rusaint/index.html?search= This example demonstrates how to initialize a USaint session using credentials, build a CourseGradesApplication client, and fetch semester grades. It utilizes the async/await pattern to handle network requests to the u-saint portal. ```rust use rusaint::application::course_grades::{CourseGradesApplication, model::CourseType, model::SemesterGrade}; use rusaint::client::USaintClientBuilder; use wdpe::element::Element; use rusaint::RusaintError; use std::sync::Arc; use rusaint::USaintSession; use futures::executor::block_on; fn main() { block_on(print_grades()); } async fn print_grades() -> Result<(), RusaintError> { let session = Arc::new(USaintSession::with_password("20211561", "password").await?); let mut app = USaintClientBuilder::new().session(session).build_into::().await?; let grades: Vec = app.semesters(CourseType::Bachelor).await?; for grade in grades { println!("{:?}", grade); } Ok(()) } ``` -------------------------------- ### Build USaintClient with USaintClientBuilder in Rust Source: https://docs.rs/rusaint/latest/rusaint/client/struct.USaintClientBuilder.html Demonstrates how to construct a USaintClient using the USaintClientBuilder. This involves creating a new builder, optionally adding a session, and then building the client with an application name. The build process is asynchronous and returns a Result which can be either a USaintClient or a WebDynproError. ```rust use rusaint::client::{USaintClient, USaintClientBuilder, USaintSession}; use std::sync::Arc; async fn build_client() -> Result { let builder = USaintClientBuilder::new(); // Optionally add a session // let session = Arc::new(USaintSession::new()); // Assuming USaintSession::new() exists // let builder = builder.session(session); let client = builder.build("my_app_name").await?; Ok(client) } ``` -------------------------------- ### GET /certificated_summary Source: https://docs.rs/rusaint/latest/src/rusaint/application/course_grades.rs.html?search=u32+-%3E+bool Retrieves the certified grade summary for all semesters. It processes the current page body to extract grade information. ```APIDOC ## GET /certificated_summary ### Description Retrieves the certified grade summary for all semesters. This method parses the current page body to extract grade information such as attempted credits, earned credits, GPA, CGPA, and average. ### Method GET ### Endpoint /certificated_summary ### Parameters #### Query Parameters - **course_type** (CourseType) - Required - The type of courses to retrieve the summary for (e.g., Bachelor, Master). ### Request Example ```json { "course_type": "Bachelor" } ``` ### Response #### Success Response (200) - **attempted_credits** (f32) - The total attempted credits. - **earned_credits** (f32) - The total earned credits. - **gpa** (f32) - The Grade Point Average. - **cgpa** (f32) - The Cumulative Grade Point Average. - **avg** (f32) - The average grade. - **pf_earned_credits** (f32) - The earned credits for Pass/Fail courses. #### Response Example ```json { "attempted_credits": 120.5, "earned_credits": 118.0, "gpa": 3.8, "cgpa": 3.9, "avg": 92.5, "pf_earned_credits": 3.0 } ``` ``` -------------------------------- ### Interact with CourseRegistrationStatusApplication in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/course_registration_status/struct.CourseRegistrationStatusApplication.html Demonstrates the core methods for managing course registration status, including fetching lecture history and refreshing the application state. ```rust pub struct CourseRegistrationStatusApplication { /* private fields */ } impl<'app> CourseRegistrationStatusApplication { pub fn get_selected_semester(&self) -> Result<(u32, SemesterType), RusaintError>; pub async fn lectures(&mut self, year: u32, semester: SemesterType) -> Result, RusaintError>; pub async fn reload(&mut self) -> Result<(), RusaintError>; } ``` -------------------------------- ### Get StudentAcademicRecord Category in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentAcademicRecord.html?search=u32+-%3E+bool Retrieves the category or type of academic record entry. This function returns the category as a string slice. ```rust pub fn category(&self) -> &str ``` -------------------------------- ### Blanket Implementations for Generic Types in Rust Source: https://docs.rs/rusaint/latest/rusaint/client/struct.USaintClient.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates various blanket implementations that apply to generic types, including Any, Borrow, BorrowMut, From, Instrument, Into, PolicyExt, TryFrom, TryInto, and WithSubscriber. These enhance the usability and interoperability of types within the Rust ecosystem. ```rust impl Any for T where T: 'static + ?Sized, impl Borrow for T where T: ?Sized, impl BorrowMut for T where T: ?Sized, impl From for T impl Instrument for T impl Into for T where U: From, impl PolicyExt for T where T: ?Sized, impl TryFrom for T where U: Into, impl TryInto for T where U: TryFrom, impl WithSubscriber for T ``` -------------------------------- ### Get StudentTeachingMajorInformation Initiation Date Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentTeachingMajorInformation.html?search= Retrieves the initiation date for the StudentTeachingMajorInformation. This method returns an Option<&str>, signifying that the date might not be present. ```Rust pub fn initiation_date(&self) -> Option<&str> ``` -------------------------------- ### Manage USaintSession authentication and persistence Source: https://docs.rs/rusaint/latest/rusaint/struct.USaintSession.html Demonstrates how to initialize a session anonymously, via credentials, or via SSO tokens, as well as how to persist session cookies to JSON. ```rust use rusaint::{USaintSession, RusaintError}; use std::io::{Write, BufRead}; // Create an anonymous session let anon = USaintSession::anonymous(); // Create a session with credentials let session = USaintSession::with_password("id", "password").await?; // Create a session with SSO token let sso_session = USaintSession::with_token("id", "token").await?; // Save session to JSON let mut buffer = Vec::new(); session.save_to_json(&mut buffer)?; // Load session from JSON let loaded_session = USaintSession::from_json(&buffer[..])?; ``` -------------------------------- ### Get StudentTeachingMajorInformation Qualification Number Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentTeachingMajorInformation.html?search= Retrieves the qualification number for the StudentTeachingMajorInformation. The method returns an Option<&str>, as the qualification number may not be available. ```Rust pub fn qualification_number(&self) -> Option<&str> ``` -------------------------------- ### Implement USaintApplication trait Source: https://docs.rs/rusaint/latest/rusaint/application/course_registration_status/struct.CourseRegistrationStatusApplication.html?search=u32+-%3E+bool Implementation of the USaintApplication trait, defining the application identifier and the constructor for initializing the application from a client. ```rust impl USaintApplication for CourseRegistrationStatusApplication { const APP_NAME: &'static str = "ZCMW2110"; fn from_client(client: USaintClient) -> Result { ... } } ``` -------------------------------- ### Get StudentAcademicRecord Process Date in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentAcademicRecord.html?search=u32+-%3E+bool Retrieves the date when the academic record was processed. This function returns the process date as a string slice. ```rust pub fn process_date(&self) -> &str ``` -------------------------------- ### Get StudentAcademicRecord Term in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentAcademicRecord.html?search=u32+-%3E+bool Retrieves the academic term (or history) for a student's record. This function returns the term as a string slice. ```rust pub fn term(&self) -> &str ``` -------------------------------- ### Define Student Information Application in Rust Source: https://docs.rs/rusaint/latest/src/rusaint/application/student_information.rs.html?search=std%3A%3Avec This snippet demonstrates the implementation of the StudentInformationApplication struct, which manages the connection to the USaint system and provides methods to query diverse student data models. ```rust use crate::client::{USaintApplication, USaintClient}; use crate::RusaintError; #[derive(Debug)] pub struct StudentInformationApplication { client: USaintClient, } impl USaintApplication for StudentInformationApplication { const APP_NAME: &'static str = "ZCMW1001n"; fn from_client(client: USaintClient) -> Result { if client.name() != Self::APP_NAME { Err(RusaintError::InvalidClientError) } else { Ok(Self { client }) } } } impl<'a> StudentInformationApplication { pub async fn family(&mut self) -> Result { Ok(StudentFamily::with_client(&mut self.client).await?) } pub async fn bank_account(&mut self) -> Result { Ok(StudentBankAccount::with_client(&mut self.client).await?) } } ``` -------------------------------- ### Retrieve Semester and Class Grades in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/course_grades/struct.CourseGradesApplication.html Shows how to fetch a list of semester grades and specific class grades, including optional detailed performance metrics. ```rust let mut app = USaintClientBuilder::new().session(session).build_into::().await.unwrap(); let semesters = app.semesters(CourseType::Bachelor).await.unwrap(); println!("{:?}", semesters); ``` ```rust let mut app = USaintClientBuilder::new().session(session).build_into::().await.unwrap(); let classes = app.classes(CourseType::Bachelor, 2022, SemesterType::Two, false).await.unwrap(); println!("{:?}", classes); ``` -------------------------------- ### Get Grade for ClassGradeItem in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/course_grades/model/struct.ClassGradeItem.html?search=u32+-%3E+bool Retrieves the letter grade or equivalent for a course. This method returns a string slice representing the grade. ```rust pub fn grade(&self) -> &str ``` -------------------------------- ### Get Score for ClassGradeItem in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/course_grades/model/struct.ClassGradeItem.html?search=u32+-%3E+bool Retrieves the numerical score obtained in a course. This method returns a string slice representing the score. ```rust pub fn score(&self) -> &str ``` -------------------------------- ### Fetch Student Work Information with Client - Rust Source: https://docs.rs/rusaint/latest/src/rusaint/application/student_information/model/work.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This asynchronous function `with_client` retrieves student work information from a Web Dynpro application using a provided `USaintClient`. It first simulates a tab selection event to navigate to the work information tab, then parses the response to extract data from various UI elements like combo boxes and input fields. The function returns a `StudentWorkInformation` struct populated with the fetched data or a `WebDynproError` if an issue occurs. ```rust pub(crate) async fn with_client( client: &mut USaintClient, ) -> Result { let mut parser = ElementParser::new(client.body()); let event = parser.read(TabStripTabSelectEventCommand::new( StudentInformationApplication::TAB_ADDITION, Self::TAB_WORK, 0, 0, ))?; client.process_event(false, event).await?; parser = ElementParser::new(client.body()); Ok(Self { job: parser.read(ComboBoxValueCommand::new(Self::COJOB)).ok(), public_official: parser .read(ComboBoxValueCommand::new(Self::COMPANY_ORGR)) .ok(), company_name: parser .read(InputFieldValueCommand::new(Self::COMPANY_NAM)) .ok(), department_name: parser .read(InputFieldValueCommand::new(Self::COMPANY_DEPT_NAM)) .ok(), title: parser .read(InputFieldValueCommand::new(Self::COMPANY_TITLE)) .ok(), zip_code: parser .read(InputFieldValueCommand::new(Self::COMPANY_ZIP_COD)) .ok(), address: parser .read(InputFieldValueCommand::new(Self::COMPANY_ADDRESS)) .ok(), specific_address: parser .read(InputFieldValueCommand::new(Self::COMPANY_ADDRESS2)) .ok(), tel_number: parser .read(InputFieldValueCommand::new(Self::COMPANY_TEL1)) .ok(), fax_number: parser .read(InputFieldValueCommand::new(Self::COMPANY_TEL2)) .ok(), }) } ``` -------------------------------- ### Build USaintClient with Session Source: https://docs.rs/rusaint/latest/src/rusaint/client.rs.html Constructs a USaintClient instance, optionally including a USaintSession for managing cookies. It initializes a reqwest::Client with a cookie provider if a session is provided, otherwise, it builds a client without session management. The client then navigates to the base URL and constructs the WebDynproState before creating the USaintClient. ```rust pub async fn build(self, name: &str) -> Result { let base_url = Url::parse(SSU_WEBDYNPRO_BASE_URL).unwrap(); let client = if let Some(session) = self.session { reqwest::Client::builder() .cookie_provider(session) .user_agent(DEFAULT_USER_AGENT) .build() .unwrap() } else { reqwest::Client::builder() .user_agent(DEFAULT_USER_AGENT) .build() .unwrap() }; let body = client.navigate(&base_url, name).await?; let state = WebDynproState::new(base_url, name.to_string(), body); USaintClient::new(state, client).await } ``` -------------------------------- ### Get StudentTeachingMajorInformation Qualification Date Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentTeachingMajorInformation.html?search= Retrieves the qualification date for the StudentTeachingMajorInformation. The method returns an Option<&str>, as the qualification date may not always be available. ```Rust pub fn qualification_date(&self) -> Option<&str> ``` -------------------------------- ### Get Lectures by Semester (Rust) Source: https://docs.rs/rusaint/latest/rusaint/application/course_registration_status/struct.CourseRegistrationStatusApplication.html?search=std%3A%3Avec Fetches a list of registered lectures for a specific student within a given academic year and semester. This is an asynchronous operation. ```rust pub async fn lectures( &mut self, year: u32, semester: SemesterType, ) -> Result, RusaintError> ``` -------------------------------- ### Create a new USaintClientBuilder in Rust Source: https://docs.rs/rusaint/latest/rusaint/client/struct.USaintClientBuilder.html Illustrates the basic creation of a USaintClientBuilder instance. The `new()` function is a simple constructor that initializes an empty builder, ready for further configuration with session or application details. ```rust use rusaint::client::USaintClientBuilder; let builder = USaintClientBuilder::new(); ``` -------------------------------- ### Get Note for ClassGradeItem in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/course_grades/model/struct.ClassGradeItem.html?search=u32+-%3E+bool Retrieves any additional notes or remarks associated with a course grade item. This method returns a string slice. ```rust pub fn note(&self) -> &str ``` -------------------------------- ### Retrieve and Print Course Grades in Rust Source: https://docs.rs/rusaint/latest/src/rusaint/lib.rs.html This example demonstrates how to authenticate with the u-saint system using a password and retrieve semester grade information. It uses the USaintClientBuilder to initialize the application and prints the resulting grade models. ```rust use rusaint::application::course_grades::{CourseGradesApplication, model::CourseType, model::SemesterGrade}; use rusaint::client::USaintClientBuilder; use rusaint::RusaintError; use std::sync::Arc; use rusaint::USaintSession; use futures::executor::block_on; fn main() { block_on(print_grades()); } async fn print_grades() -> Result<(), RusaintError> { let session = Arc::new(USaintSession::with_password("20211561", "password").await?); let mut app = USaintClientBuilder::new().session(session).build_into::().await?; let grades: Vec = app.semesters(CourseType::Bachelor).await?; for grade in grades { println!("{:?}", grade); } Ok(()) } ``` -------------------------------- ### Get Semester for ClassGradeItem in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/course_grades/model/struct.ClassGradeItem.html?search=u32+-%3E+bool Retrieves the semester in which a course grade item was taken. This method returns a string slice representing the semester. ```rust pub fn semester(&self) -> &str ``` -------------------------------- ### Get Student Number in Rust Source: https://docs.rs/rusaint/latest/src/rusaint/application/student_information/model.rs.html?search= This Rust function returns the student number. It accesses the `student_number` field from the struct. The return type is `u32`. ```rust pub fn student_number(&self) -> u32 { self.student_number } ``` -------------------------------- ### Interact with ChapelApplication in Rust Source: https://docs.rs/rusaint/latest/rusaint/application/chapel/struct.ChapelApplication.html Demonstrates the primary interface for the ChapelApplication struct, including methods to lookup data, reload the page, and retrieve specific semester information. ```rust pub struct ChapelApplication { /* private fields */ } impl<'a> ChapelApplication { pub async fn lookup(&mut self) -> Result<(), RusaintError> { ... } pub async fn reload(&mut self) -> Result<(), RusaintError> { ... } pub async fn information(&mut self, year: u32, semester: SemesterType) -> Result { ... } pub fn get_selected_semester(&self) -> Result<(u32, SemesterType), RusaintError> { ... } } ``` -------------------------------- ### Get Lifelong Education Information Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentQualification.html Retrieves the lifelong education (평생교육사) information for a student. This method returns an Option containing StudentLifelongInformation if available, otherwise None. ```rust pub fn lifelong(&self) -> Option<&StudentLifelongInformation> ``` -------------------------------- ### Generic Implementations for Any Type (Rust) Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentGraduation.html Demonstrates various blanket implementations for generic types in Rust, including Any, Borrow, BorrowMut, CloneToUninit, From, Instrument, Into, PolicyExt, ToOwned, TryFrom, and TryInto. These implementations provide common functionalities for any type that meets the specified trait bounds. ```rust impl Any for T where T: 'static + ?Sized { fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. Read more } impl Borrow for T where T: ?Sized { fn borrow(&self) -> &T Immutably borrows from an owned value. Read more } impl BorrowMut for T where T: ?Sized { fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. Read more } impl CloneToUninit for T where T: Clone { 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 } impl From for T { fn from(t: T) -> T Returns the argument unchanged. } impl Instrument for T { fn instrument(self, span: Span) -> Instrumented Instruments this type with the provided `Span`, returning an `Instrumented` wrapper. Read more fn in_current_span(self) -> Instrumented Instruments this type with the current `Span`, returning an `Instrumented` wrapper. Read more } impl Into for T where U: From { fn into(self) -> U Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. } impl PolicyExt for T where T: ?Sized { fn and(self, other: P) -> And where T: Policy, P: Policy, Create a new `Policy` that returns `Action::Follow` only if `self` and `other` return `Action::Follow`. Read more fn or(self, other: P) -> Or where T: Policy, P: Policy, Create a new `Policy` that returns `Action::Follow` if either `self` or `other` returns `Action::Follow`. Read more } impl ToOwned for T where T: Clone { type Owned = T The resulting type after obtaining ownership. fn to_owned(&self) -> T Creates owned data from borrowed data, usually by cloning. Read more fn clone_into(&self, target: &mut T) Uses borrowed data to replace owned data, usually by cloning. Read more } impl TryFrom for T where U: Into { type Error = Infallible The type returned in the event of a conversion error. fn try_from(value: U) -> Result>::Error> Performs the conversion. } impl TryInto for T where U: TryFrom { type Error = >::Error The type returned in the event of a conversion error. } ``` -------------------------------- ### Get Teaching Major Information Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentQualification.html Retrieves the teaching major (주전공) information for a student. This method returns an Option containing StudentTeachingMajorInformation if available, otherwise None. ```rust pub fn teaching_major(&self) -> Option<&StudentTeachingMajorInformation> ``` -------------------------------- ### Authenticate Session with Password (Rust) Source: https://docs.rs/rusaint/latest/rusaint/struct.USaintSession.html?search=u32+-%3E+bool Asynchronously creates a USaintSession by authenticating with a provided student ID and password. Similar to `with_token`, it returns a Result indicating success or a RusaintError. ```rust pub async fn with_password( id: &str, password: &str, ) -> Result ``` -------------------------------- ### Implement CloneToUninit for Clone types (Nightly) Source: https://docs.rs/rusaint/latest/rusaint/application/student_information/model/struct.StudentBankAccount.html?search=std%3A%3Avec Presents the nightly-only experimental API for clone_to_uninit, which performs copy-assignment from self to a mutable pointer to uninitialized memory. Requires the type to implement Clone. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) // Performs copy-assignment from `self` to `dest`. ```