mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Inital work on Rust support (#333)
* Inital work on Rust support * update accepted runtimes * fn: fix rust build * Last tweaks and README.md * fix typo * update comment on rust.go
This commit is contained in:
committed by
C Cirello
parent
3788c968eb
commit
237ab3e21b
6
examples/hello/rust/Cargo.toml
Normal file
6
examples/hello/rust/Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "func"
|
||||
version = "0.1.0"
|
||||
authors = ["Seif Lotfy <seif@iron.io>"]
|
||||
|
||||
[dependencies]
|
||||
30
examples/hello/rust/README.md
Normal file
30
examples/hello/rust/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Using rust with functions
|
||||
|
||||
The easiest way to create a iron function in rust is via ***cargo*** and ***fn***.
|
||||
|
||||
## Prerequisites
|
||||
First create an epty rust project as follows:
|
||||
```bash
|
||||
cargo init --name func --bin
|
||||
```
|
||||
|
||||
Make sure the project name is ***func*** and is of type ***bin***. Now just edit your code, once done you can create an iron function.
|
||||
|
||||
## Creating an IronFunction
|
||||
Simply run
|
||||
|
||||
```bash
|
||||
fn init --runtime=rust <username>/<funcname>
|
||||
```
|
||||
|
||||
This will create the ```func.yaml``` file required by functions, which can be built by running:
|
||||
|
||||
```bash
|
||||
fn build
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
fn run
|
||||
```
|
||||
10
examples/hello/rust/src/main.rs
Normal file
10
examples/hello/rust/src/main.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use std::io;
|
||||
use std::io::Read;
|
||||
|
||||
fn main() {
|
||||
let mut buffer = String::new();
|
||||
let stdin = io::stdin();
|
||||
if stdin.lock().read_to_string(&mut buffer).is_ok() {
|
||||
println!("Hello {}", buffer.trim());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user