Struct SubmissionList

Source
pub struct SubmissionList {
    pub submissions: Vec<Submission>,
    pub success: u8,
}
Expand description

List of submissions by a user for a task

Fields§

§submissions: Vec<Submission>§success: u8

Implementations§

Source§

impl SubmissionList

Source

pub fn best_score(&self) -> f64

get the best score achieved among all submissions

Source

pub fn get_last_high(&self) -> Option<&Submission>

get the last submission among those with highest score

Source

pub fn get_fastest_high(&self, client: &Client) -> Option<&Submission>

get the fastest submission among those with highest score

in case of parity, the latest is returned

Examples found in repository?
examples/resubmit_all.rs (line 13)
3fn main(){
4    let username = String::from("user");
5    let password = "password";
6    let mut client = Client::new(username.clone());
7    client.login(password).unwrap();
8    let user = client.get_user(&username).unwrap();
9    for sc in user.scores.unwrap() {
10        if sc.score == 100.0 {
11            println!("{} has score 100", sc.title);
12            let sub_list = client.get_submission_list(&sc.name).unwrap();
13            let best_sub = sub_list.get_fastest_high(&client).unwrap();
14            let files = &best_sub.files;
15            if files.len() == 1 { // if it is not an output-only
16                let mut submitted: bool = false;
17                print!("Resubmitting {}", sc.name.clone());
18                while !submitted { // because cmsocial has a limit to submission rate
19                    print!(".");
20                    if client
21                        .submit_normal(
22                            &sc.name,
23                            &client.get_file(&files[0]).unwrap(),
24                            files[0].name.split(".").collect::<Vec<&str>>().last().unwrap(),
25                        )
26                        .is_ok()
27                    {
28                        submitted = true;
29                    }
30                }
31                println!("");
32            }
33        }
34    }
35}

Trait Implementations§

Source§

impl Clone for SubmissionList

Source§

fn clone(&self) -> SubmissionList

Returns a copy 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 SubmissionList

Source§

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

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

impl<'de> Deserialize<'de> for SubmissionList

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 SubmissionList

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§

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> 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
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, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

Source§

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

Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,