Struct zephyr_sdk::EnvClient
source · pub struct EnvClient { /* private fields */ }
Expand description
Zephyr’s host environment client.
Implementations§
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_key(
&self,
contract: [u8; 32],
key: ScVal
) -> Result<Option<ContractDataEntry>, SdkError>
pub fn read_contract_entry_by_key( &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_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.
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 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 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) -> UpdateTable
pub fn update(&self) -> UpdateTable
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]
) -> Result<TableRows, SdkError>
pub fn db_read( &self, table_name: &str, columns: &[&str] ) -> Result<TableRows, SdkError>
Raw function to read from database.
sourcepub fn reader(&self) -> MetaReader<'_>
pub fn reader(&self) -> MetaReader<'_>
Returns the XDR reader object.
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, 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.