Crate linera_sdk
source ·Expand description
This module provides an SDK for developing Linera applications using Rust.
A Linera application consists of two WebAssembly binaries: a contract and a service.
In both binaries, there should be a shared application state. The state is a type that
represents what the application would like to persist in storage across blocks, and
must implement the Contract
trait in the contract binary and the
Service
trait in the service binary.
The application can select between two storage backends to use. Selecting the storage
backend is done by specifying both the Contract::Storage
and the Service::Storage
associated types.
The SimpleStateStorage
backend stores the application’s
state type by serializing it into binary blob. This allows the entire contents of the
state to be persisted and made available to the application when it is executed.
The ViewStateStorage
backend stores the application’s
state using the
linera-views
, a
framework that allows loading selected parts of the state. This is useful if the
application’s state is large and doesn’t need to be loaded in its entirety for every
execution.
The contract binary should use the contract!
macro to export the application’s contract
endpoints implemented via the Contract
trait implementation.
The service binary should use the service!
macro to export the application’s service
endpoints implemented via the Service
trait implementation.
Examples
The examples
directory contains some example applications.
Modules
- Types reexported from
linera_base
. - Types and macros useful for writing an application contract.
- GraphQL traits for generating interfaces into applications.
- Types and macros useful for writing an application service.
- Helper types for writing unit tests for WebAssembly applications.
- Helper types for using
linera_views
to store application state.
Macros
- Declares an implementation of the
Contract
trait, exporting it from the WASM module. - A macro for asserting that a condition is true, returning an error if it is not.
- Declares the export of the interface for the given type.
- Declares the export of the interface for the given type.
- Declares a type exporting a future declared as a WIT type.
- Declares an implementation of the
Service
trait, exporting it from the WASM module.
Structs
- The result of calling into an application.
- The context of the execution of an application’s cross-application call or session call handler.
- A logger that uses the system API for contracts.
- Externally visible results of an execution. These results are meant in the context of the application that created them.
- A future that’s exported from a guest WASM module to the host.
- The context of the execution of an application’s message.
- The context of the execution of an application’s operation.
- A message together with routing information.
- The context of the execution of an application’s query.
- A logger that uses the system API for services.
- The result of calling into a session.
- A simple state management runtime based on a single byte array.
- A state management runtime based on
linera_views
.