File tree 2 files changed +24
-0
lines changed
crates/crates_io_database/src/models/trusted_publishing
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 1
1
mod github_config;
2
+ mod token;
2
3
3
4
pub use self :: github_config:: { GitHubConfig , NewGitHubConfig } ;
5
+ pub use self :: token:: NewToken ;
Original file line number Diff line number Diff line change
1
+ use crate :: schema:: trustpub_tokens;
2
+ use chrono:: { DateTime , Utc } ;
3
+ use diesel:: prelude:: * ;
4
+ use diesel_async:: { AsyncPgConnection , RunQueryDsl } ;
5
+
6
+ #[ derive( Debug , Insertable ) ]
7
+ #[ diesel( table_name = trustpub_tokens, check_for_backend( diesel:: pg:: Pg ) ) ]
8
+ pub struct NewToken < ' a > {
9
+ pub expires_at : DateTime < Utc > ,
10
+ pub hashed_token : & ' a [ u8 ] ,
11
+ pub crate_ids : & ' a [ i32 ] ,
12
+ }
13
+
14
+ impl NewToken < ' _ > {
15
+ pub async fn insert ( & self , conn : & mut AsyncPgConnection ) -> QueryResult < ( ) > {
16
+ self . insert_into ( trustpub_tokens:: table)
17
+ . execute ( conn)
18
+ . await ?;
19
+
20
+ Ok ( ( ) )
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments