pub trait HostQuery: Send + Sync {
// Required methods
fn deserialize_and_price(
&self,
arg_buf: &[u8],
arg: &mut Box<dyn Any>,
) -> u64;
fn execute(&self, arg: &Box<dyn Any>, arg_buf: &mut [u8]) -> u32;
}Expand description
A query executable on the host.
The buffer containing the argument the contract used to call the query, together with the argument’s length, are passed as arguments to the function, and should be processed first. Once this is done, the implementor should emplace the return of the query in the same buffer, and return the length written.
Implementers of Fn(&mut [u8], u32) -> u32 can be used as a HostQuery,
but the cost will be 0.
Required Methods§
Sourcefn deserialize_and_price(&self, arg_buf: &[u8], arg: &mut Box<dyn Any>) -> u64
fn deserialize_and_price(&self, arg_buf: &[u8], arg: &mut Box<dyn Any>) -> u64
Deserialize the argument buffer and return the price of the query.
The buffer passed will be of the length of the argument the contract used to call the query.
Any information needed to perform the query after deserializing the
argument should be stored in arg, and will be passed to execute,
if there’s enough gas to execute the query.