The process of creating Rust actions is similar to that of other actions.
The following sections guide you through creating and invoking a single Rust action, and demonstrate how to bundle multiple Rust files and third party dependencies.
An example action Rust action is simply a top-level function.
For example, create a file called
hello.rs with the following source code:
Rust actions are mainly composed by a
main function that accepts a JSON
serdes Value as input and returns a
Result including a JSON
The entry method for the action is
main by default but may be specified explicitly when creating
the action with the
wsk CLI using
--main, as with any other action type.
You can create an OpenWhisk action called
helloRust from this function as follows:
The CLI automatically infers the type of the action from the source file extension.
.rs source files, the action runs using a Rust v1.34 runtime.
Action invocation is the same for Rust actions as it is for any other actions:
Find out more about parameters in the Working with parameters section.
If your action needs external dependencies, you need to provide a zip file including your source and your cargo file with all your dependencies.
The filename of the source file containing the entry point (e.g.,
main) must be
The folder structure should be as follows:
Here is an example of a Cargo.toml file
To zip your folder:
and then create the action:
Large portions of this page is copied from the Apache OpenWhisk documentation on April 23rd 2021 - where there have been customisations to match Hypi's deployment this has been noted. Apache OpenWhisk and the Apache name are the property of the Apache Foundation and licensed under the Apache V2 license .