Using Rust packages from a Motoko canister

My project is currently written entirely in Motoko. There is an SDK I would like to use (specifically the presigned function, to generate a presigned URL so my users can upload files directly to CDNs that support the S3 Object Storage interface), but the SDK isn’t available in Motoko. There is a Rust version, however.

I would like to avoid setting up a lambda on AWS just to generate this URL, so I’m thinking I could create a Rust canister that uses the SDK, add it to my project alongside my Motoko canisters, and have my Motoko canister call into that Rust canister directly when it needs to generate the URL.

Is this the right way to go about things? Are there examples you could point me to where a Motoko canister communicates with a Rust canister in the same project?

1 Like

It’s something that is being investigated, how to integrate Motoko with Rust code
But right now the way to do it is just separating the motoko and rust canisters and make calls between them

It is a bit more subtle than that. See this thread Exploration: calling Rust functions from Motoko.

If you use this and composite queries, because if the way motoko works, it is like it is on your canister. Performance should be roughly the same unless you are passing a ton of data across.