Skip to content

Commit

Permalink
Revert "chore: add CI and fix clippy lints"
Browse files Browse the repository at this point in the history
This reverts commit 022dc80.
  • Loading branch information
arnimattr committed Sep 2, 2023
1 parent 471142e commit ddc4e8b
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 37 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/ci.yml

This file was deleted.

3 changes: 3 additions & 0 deletions examples/get_timetable.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use chrono;
use untis;

///
/// This example shows a basic usecase of searching for a specific school
/// and then retrieving a user's own timetable.
Expand Down
2 changes: 2 additions & 0 deletions examples/search_for_school.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use untis;

///
/// This example shows a basic usecase of searching for schools.
///
Expand Down
6 changes: 4 additions & 2 deletions examples/view_timetables.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use untis;

///
/// This example shows how you can access a list of your school's teachers and how
/// you can view the timetables of other people/assets (i.e. rooms). Note that your
Expand Down Expand Up @@ -28,8 +30,8 @@ fn main() -> Result<(), untis::Error> {
println!(
"{}, {}-{}",
weekday(lesson.date),
*lesson.start_time,
*lesson.end_time
lesson.start_time.to_string(),
lesson.end_time.to_string()
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Client {
let params = params::AuthenticateParams {
client: "untis-rs",
user: username,
password,
password: password,
};
let mut rpc_client = jsonrpc::Client::new(&make_untis_url(server, school));
let session: Session = rpc_client.request("authenticate", params)?;
Expand Down
15 changes: 8 additions & 7 deletions src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use chrono::{Datelike, Duration, Local, NaiveDate, NaiveTime};
use serde::{self, Deserialize, Deserializer, Serialize, Serializer};
use std::ops::Deref;

/// Wrapper around `chrono::NaiveDate` for working with Untis more easily.
/// Wrapper around chrono::NaiveDate for working with Untis more easily.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub struct Date(pub NaiveDate);

Expand All @@ -25,7 +25,7 @@ impl Date {
/// Returns the last start of the week before this date.
pub fn relative_week_begin(&self) -> Self {
let days_from_monday = self.weekday().num_days_from_monday();
let monday = self.0 - Duration::days(i64::from(days_from_monday));
let monday = self.0 - Duration::days(days_from_monday as i64);
Date(monday)
}

Expand Down Expand Up @@ -73,7 +73,8 @@ impl<'de> Deserialize<'de> for Date {

fn chrono_to_untis_date(date: NaiveDate) -> u32 {
let string = format!("{}", date.format("%Y%m%d"));
string.parse::<u32>().unwrap()
let number = string.parse::<u32>().unwrap();
number
}

fn chrono_from_untis_date(value: u32) -> NaiveDate {
Expand Down Expand Up @@ -159,8 +160,8 @@ mod tests {

#[test]
fn untis_date_week_begin_is_last_monday() {
let date = Date(NaiveDate::from_ymd_opt(2023, 9, 1).unwrap());
let monday = Date(NaiveDate::from_ymd_opt(2023, 8, 28).unwrap());
let date = Date(NaiveDate::from_ymd_opt(2023, 09, 01).unwrap());
let monday = Date(NaiveDate::from_ymd_opt(2023, 08, 28).unwrap());
assert_eq!(monday, date.relative_week_begin());
}

Expand All @@ -172,8 +173,8 @@ mod tests {

#[test]
fn untis_date_week_begin_is_next_saturday() {
let date = Date(NaiveDate::from_ymd_opt(2023, 9, 1).unwrap());
let monday = Date(NaiveDate::from_ymd_opt(2023, 9, 2).unwrap());
let date = Date(NaiveDate::from_ymd_opt(2023, 09, 01).unwrap());
let monday = Date(NaiveDate::from_ymd_opt(2023, 09, 02).unwrap());
assert_eq!(monday, date.relative_week_end());
}

Expand Down
7 changes: 5 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use reqwest;
use serde_json;
use std;
use std::convert::From;
use std::fmt::{self, Display, Formatter};

Expand Down Expand Up @@ -25,8 +28,8 @@ pub enum Error {
impl Display for Error {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
let msg = match self {
Self::Reqwest(err) => format!("Reqwest error: {}", err),
Self::Serde(err) => format!("Serde Error: {}", err),
Self::Reqwest(err) => format!("Reqwest error: {}", err.to_string()),
Self::Serde(err) => format!("Serde Error: {}", err.to_string()),
Self::Http(status) => format!("HTTP Error: {}", status),
Self::Rpc(error) => format!("RPC Error: {} {}", error.code, error.message),
Self::NotFound => String::from("Resource not found"),
Expand Down
4 changes: 2 additions & 2 deletions src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl<'de> Deserialize<'de> for LessonCode {
Ok(match String::deserialize(deserializer)?.as_str() {
"irregular" => LessonCode::Irregular,
"cancelled" => LessonCode::Cancelled,
_ => LessonCode::Regular,
"regular" | _ => LessonCode::Regular,
})
}
}
Expand All @@ -360,7 +360,7 @@ impl<'de> Deserialize<'de> for LessonType {
"sb" => LessonType::Standby,
"bs" => LessonType::BreakSupervision,
"ex" => LessonType::Exam,
_ => LessonType::Lesson,
"ls" | _ => LessonType::Lesson,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/schools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn get_by_name(name: &str) -> Result<School, Error> {
}

fn get_first(mut list: Vec<School>) -> Result<School, Error> {
if list.is_empty() {
if list.len() == 0 {
Err(Error::NotFound)
} else {
Ok(list.swap_remove(0))
Expand Down

0 comments on commit ddc4e8b

Please sign in to comment.