1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/// 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.
///
pub trait Session {
/// The unique identifier of this session.
fn id(&self) -> String;
/// Useful for testing and debug.
fn is_tester(&self) -> bool;
/// Creates a copy of the current session.
///
/// # Arguments
///
/// * `newId` - The unique identifier of the copy.
///
/// Return: A copy of the current session.
///
fn clone(&self, new_id: String) -> Box<dyn 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 reset(&self, is_saved: Option<bool>);
/// Writes the session to disk.
fn save(&self);
/// Removes the session from disk.
fn delete(&self);
/// Helper functio'n to calculate overall progress of a game / rewards acquired etc.
///
/// Return: Range 0...1: with 1 representing complete.
fn percentage_complete(&self) -> f32;
/// 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.
///
fn get_session_ids(&self, suggestions: Option<Vec<String>>) -> Vec<String>;
/// 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 get_sessions(&self, suggestions: Option<Vec<String>>) -> Vec<String>;
/// Removes all session data from disk.
fn delete_all_sessions(&self);
}