@@ -29,22 +29,33 @@ pub enum CompatSessionState {
29
29
}
30
30
31
31
impl CompatSessionState {
32
- /// Returns `true` if the compta session state is [`Valid`].
32
+ /// Returns `true` if the compat session state is [`Valid`].
33
33
///
34
34
/// [`Valid`]: CompatSessionState::Valid
35
35
#[ must_use]
36
36
pub fn is_valid ( & self ) -> bool {
37
37
matches ! ( self , Self :: Valid )
38
38
}
39
39
40
- /// Returns `true` if the compta session state is [`Finished`].
40
+ /// Returns `true` if the compat session state is [`Finished`].
41
41
///
42
42
/// [`Finished`]: CompatSessionState::Finished
43
43
#[ must_use]
44
44
pub fn is_finished ( & self ) -> bool {
45
45
matches ! ( self , Self :: Finished { .. } )
46
46
}
47
47
48
+ /// Transitions the session state to [`Finished`].
49
+ ///
50
+ /// # Parameters
51
+ ///
52
+ /// * `finished_at` - The time at which the session was finished.
53
+ ///
54
+ /// # Errors
55
+ ///
56
+ /// Returns an error if the session state is already [`Finished`].
57
+ ///
58
+ /// [`Finished`]: CompatSessionState::Finished
48
59
pub fn finish ( self , finished_at : DateTime < Utc > ) -> Result < Self , InvalidTransitionError > {
49
60
match self {
50
61
Self :: Valid => Ok ( Self :: Finished { finished_at } ) ,
@@ -80,6 +91,15 @@ impl std::ops::Deref for CompatSession {
80
91
}
81
92
82
93
impl CompatSession {
94
+ /// Marks the session as finished.
95
+ ///
96
+ /// # Parameters
97
+ ///
98
+ /// * `finished_at` - The time at which the session was finished.
99
+ ///
100
+ /// # Errors
101
+ ///
102
+ /// Returns an error if the session is already finished.
83
103
pub fn finish ( mut self , finished_at : DateTime < Utc > ) -> Result < Self , InvalidTransitionError > {
84
104
self . state = self . state . finish ( finished_at) ?;
85
105
Ok ( self )
0 commit comments