Trait primitives::prelude::Session
source · [−]pub trait Session {
fn id(&self) -> String;
fn is_tester(&self) -> bool;
fn clone(&self, new_id: String) -> Box<dyn Session>;
fn reset(&self, is_saved: Option<bool>);
fn save(&self);
fn delete(&self);
fn percentage_complete(&self) -> f32;
fn get_session_ids(&self, suggestions: Option<Vec<String>>) -> Vec<String>;
fn get_sessions(&self, suggestions: Option<Vec<String>>) -> Vec<String>;
fn delete_all_sessions(&self);
}
Expand description
The Session should be implemented by objects wishing to preserve interactive information interchange.
The session can be used as both memento and arbitrator between subsystems - including entities and scenes. Sessions can be permanently stored and retrieved on future application ezecution.
Required Methods
Creates a copy of the current session.
Arguments
newId
- The unique identifier of the copy.
Return: A copy of the current session.
Reverts the session back to factory settings (as if created afresh).
Arguments
isSaved
- If true immediately writes the reset session to disk. (optional, default: false)
fn percentage_complete(&self) -> f32
fn percentage_complete(&self) -> f32
Helper functio’n to calculate overall progress of a game / rewards acquired etc.
Return: Range 0…1: with 1 representing complete.
Retrieve the collection of sessions identifiers currently saved to disk.
Arguments
suggestions
- Prepopulates results with the suggestions. (optional)
Return: A collection of sessions identifiers currently save to disk.
Retrieve the collection of sessions currently saved to disk.
Arguments
suggestions
- Prepopulates results with the suggestions. (optional)
Return: A collection of sessions currently save to disk.
fn delete_all_sessions(&self)
fn delete_all_sessions(&self)
Removes all session data from disk.