-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add async for I/O calls #372
Changes from 6 commits
7b51265
dd8fd3c
590a492
9791283
fe565b4
6e71fb8
79989c1
0e6bcda
fbad4fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use crate::errors::Result; | ||
use futures::executor::block_on; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
pub fn resolve(uri: &str) -> Self {
let inner_result = task::spawn_blocking(move || {
tokio::runtime::Handle::current().block_on(InnerResolutionResult::resolve(uri))
}).unwrap(); // Handle unwrap or any error handling as required.
Self(inner_result)
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weird, I guess uniffi requires tokio? I could've sworn I tested with futures, but oh well, guess I have to go the tokio route |
||
use web5::credentials::presentation_definition::PresentationDefinition as InnerPresentationDefinition; | ||
|
||
pub struct PresentationDefinition(pub InnerPresentationDefinition); | ||
|
@@ -13,11 +14,11 @@ impl PresentationDefinition { | |
} | ||
|
||
pub fn select_credentials(&self, vc_jwts: &Vec<String>) -> Result<Vec<String>> { | ||
Ok(self.0.select_credentials(vc_jwts)?) | ||
Ok(block_on(self.0.select_credentials(vc_jwts))?) | ||
} | ||
|
||
pub fn create_presentation_from_credentials(&self, vc_jwts: &Vec<String>) -> Result<String> { | ||
let presentation_result = self.0.create_presentation_from_credentials(vc_jwts)?; | ||
let presentation_result = block_on(self.0.create_presentation_from_credentials(vc_jwts))?; | ||
let json_serialized_presentation_result = serde_json::to_string(&presentation_result)?; | ||
|
||
Ok(json_serialized_presentation_result) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we chatted at standup, you were getting an error similar to this mozilla/uniffi-rs#2223. The solution may be that we have to specify async_runtime = tokio using uniffi proc macros as described here mozilla/uniffi-rs#2219.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed! good catch, we can improve this later