pub trait Query<T: TransportRequest + Mockable>: Send + Debug + Clone {
// Required method
fn query(self, prove: bool) -> Result<T, Error>;
}
Expand description
Trait implemented by objects that can be used as queries.
Query trait is used to specify criteria for fetching data from Platform. It can be used to specify individual objects as well as search criteria for fetching multiple objects from Platform.
Some examples of queries include:
Identifier
- fetches an object by its identifier; implemented for Identity, DataContract and Document.DocumentQuery
- fetches Document based on search conditions; see query syntax documentation for more details.
§Example
To fetch individual Identity object by its Identifier, you just need to create it and use Fetch or FetchMany trait:
use dash_sdk::{Sdk, platform::{Query, Identifier, Fetch, Identity}};
let sdk = Sdk::new_mock();
let query = Identifier::new(SOME_IDENTIFIER);
let identity = Identity::fetch(&sdk, query);
As Identifier implements Query, the query
variable in the code
above can be used as a parameter for Fetch::fetch()
and FetchMany::fetch_many() methods.
Required Methods§
sourcefn query(self, prove: bool) -> Result<T, Error>
fn query(self, prove: bool) -> Result<T, Error>
Converts the current instance into an instance of the TransportRequest
type.
This method takes ownership of the instance upon which it’s called (hence self
), and attempts to perform the conversion.
§Arguments
prove
- Whether to include proofs in the response. Onlytrue
is supported at the moment.
§Returns
On success, this method yields an instance of the TransportRequest
type (T
).
On failure, it yields an Error
.
§Error Handling
This method propagates any errors encountered during the conversion process.
These are returned as Error
instances.
Object Safety§
Implementations on Foreign Types§
source§impl Query<GetContestedResourceIdentityVotesRequest> for ContestedResourceVotesGivenByIdentityQuery
impl Query<GetContestedResourceIdentityVotesRequest> for ContestedResourceVotesGivenByIdentityQuery
source§impl Query<GetContestedResourceIdentityVotesRequest> for ProTxHash
impl Query<GetContestedResourceIdentityVotesRequest> for ProTxHash
source§impl Query<GetContestedResourceVoteStateRequest> for ContestedDocumentVotePollDriveQuery
impl Query<GetContestedResourceVoteStateRequest> for ContestedDocumentVotePollDriveQuery
source§impl Query<GetContestedResourceVotersForIdentityRequest> for ContestedDocumentVotePollVotesDriveQuery
impl Query<GetContestedResourceVotersForIdentityRequest> for ContestedDocumentVotePollVotesDriveQuery
source§impl Query<GetContestedResourcesRequest> for VotePollsByDocumentTypeQuery
impl Query<GetContestedResourcesRequest> for VotePollsByDocumentTypeQuery
source§impl Query<GetDataContractsRequest> for Vec<Identifier>
impl Query<GetDataContractsRequest> for Vec<Identifier>
source§impl Query<GetEpochsInfoRequest> for EpochIndex
impl Query<GetEpochsInfoRequest> for EpochIndex
source§impl Query<GetIdentityContractNonceRequest> for (Identifier, Identifier)
impl Query<GetIdentityContractNonceRequest> for (Identifier, Identifier)
source§impl Query<GetPathElementsRequest> for KeysInPath
impl Query<GetPathElementsRequest> for KeysInPath
source§impl Query<GetProtocolVersionUpgradeVoteStatusRequest> for Option<ProTxHash>
impl Query<GetProtocolVersionUpgradeVoteStatusRequest> for Option<ProTxHash>
Convenience method that allows direct use of a ProTxHash
source§impl Query<GetProtocolVersionUpgradeVoteStatusRequest> for ProTxHash
impl Query<GetProtocolVersionUpgradeVoteStatusRequest> for ProTxHash
Convenience method that allows direct use of a ProTxHash
source§impl Query<GetTotalCreditsInPlatformRequest> for NoParamQuery
impl Query<GetTotalCreditsInPlatformRequest> for NoParamQuery
source§impl Query<GetVotePollsByEndDateRequest> for VotePollsByEndDateDriveQuery
impl Query<GetVotePollsByEndDateRequest> for VotePollsByEndDateDriveQuery
Implementors§
impl Query<IdentityRequest> for Identifier
impl Query<IdentityRequest> for PublicKeyHash
impl Query<GetContestedResourceIdentityVotesRequest> for LimitQuery<VoteQuery>
impl Query<GetContestedResourceVoteStateRequest> for LimitQuery<ContestedDocumentVotePollDriveQuery>
impl Query<GetContestedResourceVotersForIdentityRequest> for LimitQuery<GetContestedResourceVotersForIdentityRequest>
impl Query<GetContestedResourcesRequest> for LimitQuery<GetContestedResourcesRequest>
impl Query<GetDataContractHistoryRequest> for LimitQuery<(Identifier, u64)>
impl Query<GetDataContractRequest> for Identifier
impl Query<GetEpochsInfoRequest> for EpochQuery
impl Query<GetIdentityBalanceAndRevisionRequest> for Identifier
impl Query<GetIdentityBalanceRequest> for Identifier
impl Query<GetIdentityKeysRequest> for Identifier
impl Query<GetIdentityNonceRequest> for Identifier
impl Query<GetPrefundedSpecializedBalanceRequest> for Identifier
impl Query<GetProtocolVersionUpgradeVoteStatusRequest> for LimitQuery<Option<ProTxHash>>
impl Query<GetProtocolVersionUpgradeVoteStatusRequest> for LimitQuery<ProTxHash>
Convenience method that allows direct use of a ProTxHash