11//! Providers traits, which are used during different validation procedures.
22
3- use std:: { future :: Future , time:: Duration } ;
3+ use std:: time:: Duration ;
44
55use catalyst_types:: { catalyst_id:: CatalystId , uuid:: UuidV7 } ;
66use ed25519_dalek:: VerifyingKey ;
77
88use crate :: { CatalystSignedDocument , DocumentRef } ;
99
1010/// `CatalystId` Provider trait
11+ #[ async_trait:: async_trait]
1112pub trait CatalystIdProvider : Send + Sync {
1213 /// Try to get `VerifyingKey` by the provided `CatalystId` and corresponding `RoleId`
1314 /// and `KeyRotation` Return `None` if the provided `CatalystId` with the
1415 /// corresponding `RoleId` and `KeyRotation` has not been registered.
15- fn try_get_registered_key (
16+ async fn try_get_registered_key (
1617 & self ,
1718 kid : & CatalystId ,
18- ) -> impl Future < Output = anyhow:: Result < Option < VerifyingKey > > > + Send ;
19+ ) -> anyhow:: Result < Option < VerifyingKey > > ;
1920}
2021
2122/// `CatalystSignedDocument` Provider trait
23+ #[ async_trait:: async_trait]
2224pub trait CatalystSignedDocumentProvider : Send + Sync {
2325 /// Try to get `CatalystSignedDocument` from document reference
24- fn try_get_doc (
26+ async fn try_get_doc (
2527 & self ,
2628 doc_ref : & DocumentRef ,
27- ) -> impl Future < Output = anyhow:: Result < Option < CatalystSignedDocument > > > + Send ;
29+ ) -> anyhow:: Result < Option < CatalystSignedDocument > > ;
2830
2931 /// Try to get the last known version of the `CatalystSignedDocument`, same
3032 /// `id` and the highest known `ver`.
31- fn try_get_last_doc (
33+ async fn try_get_last_doc (
3234 & self ,
3335 id : UuidV7 ,
34- ) -> impl Future < Output = anyhow:: Result < Option < CatalystSignedDocument > > > + Send ;
36+ ) -> anyhow:: Result < Option < CatalystSignedDocument > > ;
3537
3638 /// Try to get the first known version of the `CatalystSignedDocument`, `id` and `ver`
3739 /// are equal.
38- fn try_get_first_doc (
40+ async fn try_get_first_doc (
3941 & self ,
4042 id : UuidV7 ,
41- ) -> impl Future < Output = anyhow:: Result < Option < CatalystSignedDocument > > > + Send ;
43+ ) -> anyhow:: Result < Option < CatalystSignedDocument > > ;
4244
4345 /// Returns a future threshold value, which is used in the validation of the `ver`
4446 /// field that it is not too far in the future.
@@ -51,6 +53,17 @@ pub trait CatalystSignedDocumentProvider: Send + Sync {
5153 fn past_threshold ( & self ) -> Option < Duration > ;
5254}
5355
56+ /// Super trait of `CatalystSignedDocumentProvider` and `CatalystIdProvider`
57+ pub trait CatalystSignedDocumentAndCatalystIdProvider :
58+ CatalystSignedDocumentProvider + CatalystIdProvider
59+ {
60+ }
61+
62+ impl < T : CatalystSignedDocumentProvider + CatalystIdProvider >
63+ CatalystSignedDocumentAndCatalystIdProvider for T
64+ {
65+ }
66+
5467pub mod tests {
5568 //! Simple providers implementation just for the testing purposes
5669
@@ -117,6 +130,7 @@ pub mod tests {
117130 }
118131 }
119132
133+ #[ async_trait:: async_trait]
120134 impl CatalystSignedDocumentProvider for TestCatalystProvider {
121135 async fn try_get_doc (
122136 & self ,
@@ -158,6 +172,7 @@ pub mod tests {
158172 }
159173 }
160174
175+ #[ async_trait:: async_trait]
161176 impl CatalystIdProvider for TestCatalystProvider {
162177 async fn try_get_registered_key (
163178 & self ,
0 commit comments