levana_perpswap_cosmos/
result.rs

1use anyhow::Result;
2use cosmwasm_std::{to_json_binary, QueryResponse};
3use serde::Serialize;
4/// Makes it easy to call .query_result() on any Serialize
5/// and standardizes so query() entry points also return a ContractResult
6pub trait QueryResultExt {
7    /// Convert the value to its JSON representation
8    fn query_result(&self) -> Result<QueryResponse>;
9}
10impl<T: Serialize> QueryResultExt for T {
11    fn query_result(&self) -> Result<QueryResponse> {
12        to_json_binary(self).map_err(|err| err.into())
13    }
14}