Crate edjx

source ·
Expand description

EDJX Library SDK for Rust

This crate contains the EDJX SDK library for Rust. This SDK is used to develop EDJX serverless functions. In this version, functions are triggered using HTTP only.

Additionally, developers can use the streaming feature while building serverless functions. Streaming optimizes data transfer (upload file/download file) to the EDJX object storage, and HTTP transfers. Using the streaming feature, developers can work with large data sets without allocating huge memory to the functions. Since functions process data as smaller chunks, the use of streaming in functions drastically reduces the response time.

EDJX HTTP Trigger Functions

These functions are triggered from standard HTTP methods. The input for the function is an HTTP Request object (represented by HttpRequest in the EDJX SDK) and the return value must be an HTTP Response object (represented by HttpResponse in the EDJX SDK).

EDJX sample Rust Serverless Application has two Rust files :

  1. : This file contains helper code to fetch HTTP Requests and pass the request as input to the serverless function being developed. Additionally, this file has code related to HTTP Response processing. Modify this file only when a mutable reference to the request is required, or the HTTP Response type needs to be changed. See HttpRequest and HttpResponse for more details.
pub fn init() {
    let req = match HttpRequest::from_client() {
        Ok(val) => val,
        Err(e) => {
            error!("{}", e.to_string().as_str());

  let res = crate::serverless_function::serverless(req);
    match res.send() {
        Ok(x) => x,
        Err(e) => {
            error!("{}", e.to_string().as_str());
  1. : This file contains the code to create a Serverless Function.
pub fn serverless(req: HttpRequest) -> HttpResponse {
    return HttpResponse::from("Success from EDJX".to_string())

HttpRequest is read-only, that is, it has only methods to read input HTTP Request.

Both HttpRequest and HttpResponse APIs are similar to standard RUST HTTP interface. The other important HTTP structs like Headers, Method, StatusCode, and Version are similar to standard RUST HTTP interface.

Two other important structures in this crate are HttpFetch and FetchResponse. HttpFetch is used to execute HTTP Requests. FetchResponse is returned as a response to a Fetch Request. Both these types APIs are similar to standrard RUST HTTP interface

HTTP body size limits

Currently, all HTTP APIs have a size limit of 512 MB for the HTTP body.

Interacting with the EDJX Object Store and KV Store

The most important APIs in the EDJX Library SDK are those used to interact with the Object Storage (represented by storage in the EDJX SDK ) and the KV Store (represented by kv in the EDJX SDK)

The Object Store is a decentralized datastore backed by the EDJX P2P network. This SDK uses GET and PUT methods for file contents and associated attributes.

The KV Store is a decentralized Key-Value datastore backed by the EDJX P2P network. Key size is limited to 512 bytes and Value is limited to 512 KB.


This SDK provides generic Rust-compatible logger APIs similar to standard RUST Log.


pub use fetch::HttpFetch;
pub use request::HttpMethod;
pub use request::HttpRequest;
pub use response::HttpResponse;
pub use stream::BaseStream;
pub use stream::ReadStream;
pub use stream::WriteStream;


Error handling enums and utilities.
APIs for executing HTTP requests.
APIs for interacting with EDJX KV-Store.
Read-only HTTP request input for HTTP-trigger serverless functions.
APIs used to send HTTP Responses for HTTP-triggered serverless functions.
APIs for interacting with the EDJX Object Store.
APIs for manipulating data streams.


Logs a message at the debug level.
Logs a message at the error level.
Logs a message at the fatal level.
Logs a message at the info level.
Logs a message at the trace level.
Logs a message at the warn level.


Response for HTTP fetch request, which may include body, headers, and status code.
FetchResponsePending is a placeholder for the HTTP server’s response. It is returned when crate::fetch::HttpFetch::send_streaming is called. It is then used to retrive FetchResponse from the server.
Represents the attributes associated with a stored file.
A set of HTTP headers
Represents an HTTP header field name
Represents an HTTP header field value.
The Request Method (VERB)
An HTTP status code (status-code in RFC 7230 et al.).
Response to the crate::storage::get request.
StorageResponsePending is a placeholder for the EDJX Object Store’s response. It is returned when crate::storage::put_streaming is called. It is used to retrive a StorageResponse once it is ready.
The URI component of a request.


An enum representing the available verbosity levels of the logger.