[][src]Struct cms_tools::Client

pub struct Client {
    pub client: Client,
    pub username: String,
    pub logged: bool,
}

Client you will do almost everything with

Fields

client: Client

The reqwest client

username: String

username

logged: bool

if client has token, this should be true and false otherwise

Methods

impl Client[src]

Client functions return:

  • Err(1) if request is not Ok, usually when server is unreachable
  • Err(2) when json cannot be parsed, usually unreachable or due to incorrect parameters
  • Err(3) if the json contains success=0

pub fn new(username: String) -> Self[src]

create a new client with given username.

always use this to create a client

for requests you don't need to be logged in to do, username will not be used

pub fn login(&mut self, password: &str) -> Result<bool, u8>[src]

login with self.username and password

Returns Ok(true) if the client was already logged and Ok(false) if it was not and succeeds in logging

example is drop-down menu on the top-right corner

pub fn recover(&self, email: &str, code: &str) -> Result<RecoverResponse, u8>[src]

recover lost password, use empty code to get the email

example cms page

pub fn user_update(
    &self,
    email: &str,
    password: &str,
    old_password: &str
) -> Result<(), u8>
[src]

update password/email, empty string for fields you dont want to update

example cms page

pub fn check_username(&self, username: &str) -> Result<CheckResponse, u8>[src]

check if username is valid, note: Ok does not mean username is valid

example is Username input

pub fn check_email(&self, email: &str) -> Result<CheckResponse, u8>[src]

check if email is valid, note: Ok does not mean email is valid

example is E-mail address input

pub fn check_password(&self, password: &str) -> bool[src]

check if password is valid, note: this is done locally

unlike other functions, this returs true if password is acceptable and false otherwise

example is Password input

pub fn user_exists(&self, username: &str) -> Result<bool, u8>[src]

check if there is an user with username = username

example is Username input

pub fn get_user_list(&self, first: usize, last: usize) -> Result<UserList, u8>[src]

get list of users in reverse order of score in [first,last)

example cms page

pub fn get_user(&self, username: &str) -> Result<User, u8>[src]

get the details of a specific user

example cms page

pub fn get_task_list(
    &self,
    first: usize,
    last: usize,
    order: &str,
    tag: Option<&str>,
    search: Option<&str>
) -> Result<TaskList, u8>
[src]

get list of tasks in [first,last) in the given order with the given tag that matches search

possible orders are: newest, easiest, hardest

if an invalid order is given, it is assumed to be newest

example cms page

pub fn get_task(&self, name: &str) -> Result<DetailedTask, u8>[src]

get the details of a specific task

example cms page

pub fn get_stats(&self, name: &str) -> Result<Stats, u8>[src]

get the statistics for a specific task

example cms page

pub fn get_submission_list(&self, task_name: &str) -> Result<SubmissionList, u8>[src]

get your submissions for a task

example cms page

pub fn get_submission(&self, id: usize) -> Result<DetailedSubmission, u8>[src]

get details for specific submission

example is clicking on submission id

pub fn submit_normal(
    &self,
    task_name: &str,
    text: &str,
    lang: &str
) -> Result<DetailedSubmission, u8>
[src]

submit a not output-only task

lang should be the extension of the file (c, cpp, pas)

example is clicking on submit button

pub fn get_test_list(&self) -> Result<TestList, u8>[src]

get the list of available tests

example cms page

pub fn get_test(&self, test_name: &str) -> Result<Test, u8>[src]

get the details and text of a specific test

example cms page

pub fn get_region_list(&self) -> Result<RegionList, u8>[src]

Misc get a list of the regions

example cms page

pub fn get_technique_list(&self) -> Result<TechniqueList, u8>[src]

get list of technique tags

example cms page

pub fn get_file(&self, file: &File) -> Result<String, u8>[src]

Auto Trait Implementations

impl Send for Client

impl Sync for Client

impl Unpin for Client

impl !UnwindSafe for Client

impl !RefUnwindSafe for Client

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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

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