pub struct EnvClient { /* private fields */ }
Expand description
Zephyr’s host environment client.
Implementations§
source§impl EnvClient
impl EnvClient
sourcepub fn from_scval<T: TryFromVal<Env, Val>>(&self, scval: &ScVal) -> T
pub fn from_scval<T: TryFromVal<Env, Val>>(&self, scval: &ScVal) -> T
Converts an ScVal into a soroban host object. Returns a Soroban Val. Panics when the conversion fails.
sourcepub fn try_from_scval<T: TryFromVal<Env, Val>>(
&self,
scval: &ScVal,
) -> Result<T, SdkError>
pub fn try_from_scval<T: TryFromVal<Env, Val>>( &self, scval: &ScVal, ) -> Result<T, SdkError>
Converts an ScVal into a soroban host object. Returns a Soroban Val. Returns an error when the conversion fails.
sourcepub fn to_scval<T: TryIntoVal<Env, Val>>(&self, val: T) -> ScVal
pub fn to_scval<T: TryIntoVal<Env, Val>>(&self, val: T) -> ScVal
Converts an environment object to the corresponding scval xdr representation.
sourcepub fn scval_to_valid_host_val<T: TryFromVal<Env, Val>>(
&self,
scval: &ScVal,
) -> Result<T, SdkError>
pub fn scval_to_valid_host_val<T: TryFromVal<Env, Val>>( &self, scval: &ScVal, ) -> Result<T, SdkError>
Converts an ScVal into a soroban host object. Returns a result with a Soroban Val.
sourcepub fn send_web_request(&self, request: AgnosticRequest)
pub fn send_web_request(&self, request: AgnosticRequest)
Sends a web request message requests to the host.
sourcepub fn read<T: DatabaseInteract>(&self) -> Vec<T>
pub fn read<T: DatabaseInteract>(&self) -> Vec<T>
Reads a database table.
This function uses the DatabaseInteract
trait
along with the DatabaseDerive
macro to read the rows
into a DatabaseDerive
struct.
sourcepub fn read_filter(&self) -> TableQueryWrapper
pub fn read_filter(&self) -> TableQueryWrapper
Read a database table applying a column-level filter. Returns a filter object.
sourcepub fn put<T: DatabaseInteract>(&self, row: &T)
pub fn put<T: DatabaseInteract>(&self, row: &T)
Writes a row to a database table.
This function uses the DatabaseInteract
trait
along with the DatabaseDerive
macro to write the row
derived from the DatabaseDerive
struct.
sourcepub fn update(&self) -> TableQueryWrapper
pub fn update(&self) -> TableQueryWrapper
Updates a row to a database table.
This function uses the DatabaseInteract
trait
along with the DatabaseDerive
macro to update the row
derived from the DatabaseDerive
struct.
sourcepub fn update_inner<T: DatabaseInteract>(
&self,
row: &T,
conditions: &[Condition],
)
pub fn update_inner<T: DatabaseInteract>( &self, row: &T, conditions: &[Condition], )
Updates a row to a database table.
This function uses the DatabaseInteract
trait
along with the DatabaseDerive
macro to update the row
derived from the DatabaseDerive
struct.
sourcepub fn db_write(
&self,
table_name: &str,
columns: &[&str],
segments: &[&[u8]],
) -> Result<(), SdkError>
pub fn db_write( &self, table_name: &str, columns: &[&str], segments: &[&[u8]], ) -> Result<(), SdkError>
Raw function to write to the database a row.
sourcepub fn db_update(
&self,
table_name: &str,
columns: &[&str],
segments: &[&[u8]],
conditions: &[Condition],
) -> Result<(), SdkError>
pub fn db_update( &self, table_name: &str, columns: &[&str], segments: &[&[u8]], conditions: &[Condition], ) -> Result<(), SdkError>
Raw function to update a database row.
sourcepub fn db_read(
&self,
table_name: &str,
columns: &[&str],
external: Option<i64>,
conditions: Option<&[Condition]>,
) -> Result<TableRows, SdkError>
pub fn db_read( &self, table_name: &str, columns: &[&str], external: Option<i64>, conditions: Option<&[Condition]>, ) -> Result<TableRows, SdkError>
Raw function to read from database.
sourcepub fn reader(&self) -> MetaReader<'_>
pub fn reader(&self) -> MetaReader<'_>
Returns the XDR reader object.
sourcepub fn conclude<T: Serialize>(&self, result: T)
pub fn conclude<T: Serialize>(&self, result: T)
Send a result to the host.
This function has no effect when used in ingestion zephyr programs and should only be used with serverless functions as target.
sourcepub fn read_request_body<'a, T: Deserialize<'a>>(&self) -> T
pub fn read_request_body<'a, T: Deserialize<'a>>(&self) -> T
Read request body into the specified format type.
sourcepub fn simulate_contract_call(
&self,
source: String,
contract: [u8; 32],
fname: Symbol,
args: Vec<Val>,
) -> Result<InvokeHostFunctionSimulationResult, SdkError>
pub fn simulate_contract_call( &self, source: String, contract: [u8; 32], fname: Symbol, args: Vec<Val>, ) -> Result<InvokeHostFunctionSimulationResult, SdkError>
Wrapper around self.simulate. This is a simpler SDK handler which
source§impl EnvClient
impl EnvClient
sourcepub fn read_contract_instance(
&self,
contract: [u8; 32],
) -> Result<Option<ContractDataEntry>, SdkError>
pub fn read_contract_instance( &self, contract: [u8; 32], ) -> Result<Option<ContractDataEntry>, SdkError>
Returns the instance object of a certain contract from the host’s ledger.
sourcepub fn read_contract_entry_by_scvalkey(
&self,
contract: [u8; 32],
key: ScVal,
) -> Result<Option<ContractDataEntry>, SdkError>
pub fn read_contract_entry_by_scvalkey( &self, contract: [u8; 32], key: ScVal, ) -> Result<Option<ContractDataEntry>, SdkError>
Returns the requested entry object of a certain contract from the host’s ledger.
sourcepub fn read_full_contract_entry_by_key<T: TryIntoVal<Env, Val>>(
&self,
contract: [u8; 32],
val: T,
) -> Result<Option<ContractDataEntry>, SdkError>
pub fn read_full_contract_entry_by_key<T: TryIntoVal<Env, Val>>( &self, contract: [u8; 32], val: T, ) -> Result<Option<ContractDataEntry>, SdkError>
Returns the whole requested entry object of a certain contract from the host’s ledger.
sourcepub fn read_contract_entry_by_key<T: TryIntoVal<Env, Val>, R: TryFromVal<Env, Val> + Debug>(
&self,
contract: [u8; 32],
val: T,
) -> Result<Option<R>, SdkError>
pub fn read_contract_entry_by_key<T: TryIntoVal<Env, Val>, R: TryFromVal<Env, Val> + Debug>( &self, contract: [u8; 32], val: T, ) -> Result<Option<R>, SdkError>
Returns the requested entry object of a certain contract from the host’s ledger.
sourcepub fn read_contract_entries(
&self,
contract: [u8; 32],
) -> Result<Vec<ContractDataEntry>, SdkError>
pub fn read_contract_entries( &self, contract: [u8; 32], ) -> Result<Vec<ContractDataEntry>, SdkError>
Returns all the entry objects of a certain contract from the host’s ledger.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EnvClient
impl !RefUnwindSafe for EnvClient
impl !Send for EnvClient
impl !Sync for EnvClient
impl Unpin for EnvClient
impl !UnwindSafe for EnvClient
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W), ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
source§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X), ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.