pub struct Process;Expand description
Utilities for managing process-level operations.
Implementations§
Source§impl Process
impl Process
Sourcepub fn args() -> Vec<String>
pub fn args() -> Vec<String>
Returns a vector of command-line arguments passed to the program.
§Examples
use seda_sdk_rs::process::Process;
let args = Process::args();
// args[0] is the program name
// args[1] would be the first argumentSourcepub fn envs() -> BTreeMap<String, String>
pub fn envs() -> BTreeMap<String, String>
Returns a map of all environment variables.
§Examples
use seda_sdk_rs::process::Process;
std::env::set_var("TEST_VAR", "test_value");
let env_vars = Process::envs();
assert!(env_vars.contains_key("TEST_VAR"));
for (key, value) in env_vars {
println!("{}: {}", key, value);
}Sourcepub fn get_inputs() -> Vec<u8> ⓘ
pub fn get_inputs() -> Vec<u8> ⓘ
Retrieves and decodes the data request inputs
§Panics
This function will panic if:
- There were no arguments passed to the program.
- The second argument (index 1) is not a valid hex string.
§Examples
use seda_sdk_rs::process::Process;
let input_bytes = Process::get_inputs();
// Process the input bytes...Sourcepub fn is_tally_vm_mode() -> bool
pub fn is_tally_vm_mode() -> bool
Checks if the current VM mode is set to tally mode.
§Examples
use seda_sdk_rs::process::Process;
std::env::set_var("VM_MODE", "tally");
if Process::is_tally_vm_mode() {
// Handle tally mode specific logic
}Sourcepub fn is_dr_vm_mode() -> bool
pub fn is_dr_vm_mode() -> bool
Checks if the current VM mode is set to DR mode.
§Examples
use seda_sdk_rs::process::Process;
if Process::is_dr_vm_mode() {
let replication = Process::replication_factor();
// Handle DR mode specific logic
}Sourcepub fn success(result: &[u8]) -> !
pub fn success(result: &[u8]) -> !
Exits the process successfully (code 0) with the given result.
§Examples
use seda_sdk_rs::process::Process;
let result = vec![0x01, 0x02, 0x03];
Process::success(&result);Sourcepub fn error(result: &[u8]) -> !
pub fn error(result: &[u8]) -> !
Exits the process with an error (code 1) and the given result.
§Examples
use seda_sdk_rs::process::Process;
let error_data = vec![0xFF];
Process::error(&error_data);Sourcepub fn replication_factor() -> u16
pub fn replication_factor() -> u16
Gets the replication factor for the data request
§Panics
This function will panic if:
- The
DR_REPLICATION_FACTOR_ENV_KEYenvironment variable is not set. - The value of
DR_REPLICATION_FACTOR_ENV_KEYis not a validu16.
These conditions should never happen in a properly configured environment.
§Examples
use seda_sdk_rs::process::Process;
if Process::is_dr_vm_mode() {
let factor = Process::replication_factor();
println!("Replication factor: {}", factor);
}Sourcepub fn exit_with_message(code: u8, message: &str) -> !
pub fn exit_with_message(code: u8, message: &str) -> !
Exits the process with the given code and message.
§Examples
use seda_sdk_rs::process::Process;
// Exit with an error message
Process::exit_with_message(1, "Operation failed: invalid input");
// Exit with success message
Process::exit_with_message(0, "Operation completed successfully");Auto Trait Implementations§
impl Freeze for Process
impl RefUnwindSafe for Process
impl Send for Process
impl Sync for Process
impl Unpin for Process
impl UnwindSafe for Process
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more