Crate store_flows

source ·
Expand description

Give the flow function the ability to store key/value in Flows.network

Quick Start

To get started, let’s write a very tiny flow function.

use serde_json::json;
use lambda_flows::{request_received, send_response};
use store_flows::{get, set};

#[no_mangle]
pub fn run() {
    if let Some((_qry, _body)) = request_received() {
        let mut c = match get("count") {
            Some(v) => v.as_u64().unwrap_or_default(),
            None => 0,
        };

        c = c + 1;

        set("count", json!(c));

        send_response(
            200,
            vec![(String::from("content-type"), String::from("text/html"))],
            c.to_string().as_bytes().to_vec(),
        );
    }
}

In this lambda service flow function, use set() and get() to store and return the times it has been called.

Functions

Delete the stored key/value pair.
Retrieve the stored value by the key.
Store the key/value pair.