Struct sf_api::session::CharacterSession

source ·
pub struct CharacterSession { /* private fields */ }

Implementations§

source§

impl CharacterSession

source

pub fn new(username: &str, password: &str, server: ServerConnection) -> Self

source

pub fn new_hashed( username: &str, pw_hash: PWHash, server: ServerConnection ) -> Self

source

pub fn server_url(&self) -> &Url

source

pub fn has_session_id(&self) -> bool

Checks if this session has ever been able to successfully login to the server to establish a session id. You should not need to check this, as login() should return error on unsuccessfull logins, but if you want to make sure, you can make sure here

source

pub async fn login(&mut self) -> Result<Response, SFError>

Clears the current session and sends a login request to the server. Returns the parsed response from the server.

source

pub async fn register( username: &str, password: &str, server: ServerConnection, gender: Gender, race: Race, class: Class ) -> Result<(Self, Response), SFError>

Registers a new character on the server. If everything works, the logged in character session and its login response will be returned

source

pub async fn send_command_raw( &self, command: &Command ) -> Result<Response, SFError>

The internal version send_command. It allows you to send requests with only a normal ref, because this version does not update the cryptography settings of this session, if the server responds with them. If you do not expect the server to send you new crypto settings, because you only do predictable simple requests (no login, etc), or you want to update them yourself, because that is easier to handle for you, you can use this function to increase your commands/account/sec speed

source

pub async fn send_command( &mut self, command: &Command ) -> Result<Response, SFError>

Encode and send a command to the server, decrypts and parses its response and returns the response. When this returns an error, the Session might be in an invalid state, so you should login again just to be safe

source

pub fn update(&mut self, res: &Response)

source

pub fn username(&self) -> &str

source

pub async fn renew_sso_creds(&mut self) -> Result<(), SFError>

Retrieves new sso credentials from its sf account. If the account already has new creds stored, these are read, otherwise the account will be logged in again

Trait Implementations§

source§

impl Clone for CharacterSession

source§

fn clone(&self) -> CharacterSession

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 CharacterSession

source§

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

Formats the value using the given formatter. 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more