Crate rs_zephyr_sdk
source ·Expand description
Zephyr Rust SDK
The zephyr rust sdk aids developers in writing programs for the Zephyr Virtual Machine.
§Hello Ledger Example
use rs_zephyr_sdk::{bincode, log, stellar_xdr::next::{Limits, WriteXdr}, Condition, DatabaseDerive, DatabaseInteract, EnvClient, ZephyrVal};
#[derive(DatabaseDerive, Clone)]
#[with_name("curr_seq")]
struct Sequence {
pub current: u32,
}
#[no_mangle]
pub extern "C" fn on_close() {
let env = EnvClient::new();
let reader = env.reader();
let sequence = Sequence {
current: reader.ledger_sequence()
};
if let Some(last) = Sequence::read_to_rows(&env).iter().find(|x| x.current == sequence.current - 1) {
sequence.update(&env, &[Condition::ColumnEqualTo("current".into(), bincode::serialize(&ZephyrVal::U32(last.current)).unwrap())]);
} else {
sequence.put(&env)
}
}
Re-exports§
pub use soroban_sdk;
pub use stellar_xdr;
pub use bincode;
Modules§
- Some sparse scval utils. Note that these might be deprecated in the future.
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.
- Ledger meta reader.
- 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.