Expand description
Zephyr Rust SDK
The zephyr rust sdk aids developers in writing programs for the Zephyr Virtual Machine.
§Hello Ledger Example
use zephyr_sdk::{prelude::*, soroban_sdk::xdr::{ScString, ScVal}, EnvClient, DatabaseDerive};
#[derive(DatabaseDerive, Clone)]
#[with_name("test")]
struct TestTable {
hello: ScVal,
}
#[no_mangle]
pub extern "C" fn on_close() {
let env = EnvClient::new();
let sequence = env.reader().ledger_sequence();
env.log().debug(format!("Got sequence {}", sequence), None);
let message = {
let message = format!("World at ledegr sequence {}", sequence);
ScVal::String(ScString(message.try_into().unwrap()))
};
let table = TestTable {
hello: message.clone(),
};
env.log().debug(
"Writing to the database",
Some(bincode::serialize(&message).unwrap()),
);
table.put(&env);
env.log().debug("Successfully wrote to the database", None);
}
Re-exports§
pub use soroban_sdk;
pub use bincode;
Modules§
- Charting utilities and wrappers.
- Zephyr SDK prelude.
- Utilities for working with common data patterns.
Structs§
- A generic request object meant to be easily reusable by any HTTP client request.
- Represents all of the entry changes that happened in the ledger close.
- Zephyr’s host environment client.
- Logger object.
- Ledger meta reader.
- Pretty representation of a Soroban event.
- Wraps a single row.
- Object returned by database reads. It’s a wrapper for table rows.
Enums§
- Condition clauses that can be applied when reading the database.
- Methods currently supported are Get and Post.
- Zephyr SDK errors.
Traits§
- Trait that DatabaseDerive structures implement