-
-
Notifications
You must be signed in to change notification settings - Fork 502
Closed
Description
Here's an example:
fn ipfs_client(ctx: &Context<'_>) -> Result<IpfsClient, InvalidUri> {
let app_data = ctx.data::<AppData>();
IpfsClient::from_str(&app_data.ipfs_url)
}
async fn create_asset(
&self,
ctx: &Context<'_>,
file: Upload,
) -> FieldResult<Asset> {
if true {
let reader = File::open(file.path)?;
let ipfs_client = ipfs_client(ctx)?;
let resp = ipfs_client.add(reader).await.map_err(|err| {
ErrorKind::Fatal(format!("Failed to add a file to IPFS: {:?}", err))
})?;
ipfs_hash = resp.hash;
}
}
The Object macro on MutationRoot
#[Object]
impl MutationRoot {
Would throw an error:
69 | #[Object]
| ^^^^^^^^^ future returned by `__resolve_field` is not `Send`
|
= help: within `impl core::future::future::Future`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<awc::ClientConfig>`
and also
| `std::rc::Rc<std::cell::RefCell<actix_http::h1::payload::Inner>>` cannot be sent between threads safely
For the result of the add
operation.
For the record: I'm not trying to pass the ipfs_client around, I instantiate it when it's needed, get a result and throw it away.
Metadata
Metadata
Assignees
Labels
No labels