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§

utils
Some sparse scval utils. Note that these might be deprecated in the future.

Structs§

AgnosticRequest
A generic request object meant to be easily reusable by any HTTP client request.
ContractDataEntry
EntryChanges
Represents all of the entry changes that happened in the ledger close.
EnvClient
Zephyr’s host environment client.
MetaReader
Ledger meta reader.
TableRow
Wraps a single row.
TableRows
Object returned by database reads. It’s a wrapper for table rows.

Enums§

Condition
Condition clauses that can be applied when reading the database.
Method
Methods currently supported are Get and Post.
SdkError
Zephyr SDK errors.
ZephyrVal

Traits§

DatabaseInteract

Derive Macros§

DatabaseDerive