/// 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](https://training.olinfo.it/#/overview)
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]
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 login(&mut self, password: &str) -> Result<bool, u8> {
        if self.logged {
            return Ok(true);
        }
        match self.client.post("https://training.olinfo.it/api/user").json(&serde_json::json!({"action":"login","keep_signed":"false","username":self.username,"password":password})).send() {
            Ok(mut response) => {
                #[derive(serde::Serialize, serde::Deserialize)]
                struct Resp{
                    success: u8
                }
                match response.json::<Resp>() {
                    Ok(resp) => {
                        match resp.success {
                            1 => {
                                self.logged = true;
                                Ok(false)
                            }
                            _ => Err(3)
                        }
                    },
                    _ => {
                        Err(2)
                    }
                }
            },
            _ => {
                Err(1)
            }
        }
    }
pub fn login ( & mut self , password : & str ) -> Result < bool , u8 > { if self . logged { return Ok ( true ) ; } match self . client . post ( " " ) . json ( & serde_json :: json ! ( { " " " " " " " " " " self username " " password } ) ) . send ( ) { Ok ( mut response ) => { # [ derive ( serde Serialize serde Deserialize ) ] struct Resp { success : u8 } match response . json :: < Resp > ( ) { Ok ( resp ) => { match resp . success { 1 => { self . logged = true ; Ok ( false ) } _ => Err ( 3 ) } } , _ => { Err ( 2 ) } } } , _ => { Err ( 1 ) } } }
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
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
&mut self
password
&str