pub struct SimpleSession { /* private fields */ }
Implementations§
Source§impl SimpleSession
impl SimpleSession
Sourcepub async fn login(
username: &str,
password: &str,
server_url: &str,
) -> Result<Self, SFError>
pub async fn login( username: &str, password: &str, server_url: &str, ) -> Result<Self, SFError>
Creates a new SimpleSession
, by logging in a normal S&F character
§Errors
Have a look at send_command
for a full list of possible errors
Sourcepub async fn login_sf_account(
username: &str,
password: &str,
) -> Result<Vec<Self>, SFError>
pub async fn login_sf_account( username: &str, password: &str, ) -> Result<Vec<Self>, SFError>
Creates new SimpleSession
s, by logging in the S&S SSO account and
returning all the characters associated with the account
§Errors
Have a look at send_command
for a full list of possible errors
Sourcepub fn game_state(&self) -> Option<&GameState>
pub fn game_state(&self) -> Option<&GameState>
Returns a reference to the game state, if this SimpleSession
is
currently logged in
Sourcepub fn game_state_mut(&mut self) -> Option<&mut GameState>
pub fn game_state_mut(&mut self) -> Option<&mut GameState>
Returns a mutable reference to the game state, if this SimpleSession
is currently logged in
Sourcepub async fn send_command<T: Borrow<Command>>(
&mut self,
cmd: T,
) -> Result<&mut GameState, SFError>
pub async fn send_command<T: Borrow<Command>>( &mut self, cmd: T, ) -> Result<&mut GameState, SFError>
Sends the command and updates the gamestate with the response from the server. A mutable reference to the gamestate will be returned. If an error is encountered, the gamestate is cleared and the error will be returned. If you send a command after that, this function will try to login this session again, before sending the provided command
§Errors
EmptyResponse
: If the servers response was emptyInvalidRequest
: If your response was invalid to send in some wayConnectionError
: If the command could not be send, or the response could not successfully be receivedParsingError
: If the response from the server was unexpected in some wayTooShortResponse
Similar toParsingError
, but specific to a response being too short, which would normally trigger a out of bound panicServerError
: If the server itself responded with an ingame error like “you do not have enough silver to do that”