-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate session into pmrac::Platform
- Also provide a linked session type that will provide methods that use the platform reference (i.e. works like a handle/ctrl). - Discovered that it may be best to save a new token without updating the timestamp further to maintain certain expectations. - Have no idea how to address saving. Perhaps make it so that calling save returns the token (i.e. make the argument just `self`). Will revisit this later.
- Loading branch information
1 parent
cb9dd35
commit daec733
Showing
7 changed files
with
206 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
pub mod error; | ||
pub mod password; | ||
pub mod platform; | ||
pub mod session; | ||
pub mod user; | ||
|
||
pub use platform::Platform; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use pmrcore::ac::session; | ||
|
||
use crate::{ | ||
Platform, | ||
user::User, | ||
}; | ||
|
||
pub struct Session<'a> { | ||
platform: &'a Platform, | ||
session: session::Session, | ||
user: User<'a>, | ||
} | ||
|
||
mod impls; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use pmrcore::ac::session; | ||
|
||
use crate::{ | ||
Platform, | ||
error::Error, | ||
user::User, | ||
}; | ||
use super::Session; | ||
|
||
impl<'a> Session<'a> { | ||
pub(crate) fn new( | ||
platform: &'a Platform, | ||
session: session::Session, | ||
user: User<'a>, | ||
) -> Self { | ||
Self { | ||
platform, | ||
session, | ||
user, | ||
} | ||
} | ||
|
||
pub fn user(&self) -> &User<'a> { | ||
&self.user | ||
} | ||
|
||
// access to every field, which may or may not be what we want. | ||
pub fn session(&self) -> &session::Session { | ||
&self.session | ||
} | ||
|
||
// consider making the argument `self` to consume, and not worry | ||
// about dealing with the timestamp at all? | ||
pub async fn save(&self) -> Result<i64, Error> { | ||
Ok(self.platform | ||
.ac_platform() | ||
.save_session(&self.session) | ||
.await?) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ca9e267e66cb1b4d18d5bfd89ecc092459a6.json → ...257e91fbc517d61e5e54b1f372a6031e0ec8.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters