Trait dash_sdk::platform::Query

source ·
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:

  1. Identifier - fetches an object by its identifier; implemented for Identity, DataContract and Document.
  2. 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§

source

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. Only true 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§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Query<GetContestedResourceIdentityVotesRequest> for ContestedResourceVotesGivenByIdentityQuery

source§

impl Query<GetContestedResourceIdentityVotesRequest> for ProTxHash

source§

impl Query<GetContestedResourceVoteStateRequest> for ContestedDocumentVotePollDriveQuery

source§

impl Query<GetContestedResourceVotersForIdentityRequest> for ContestedDocumentVotePollVotesDriveQuery

source§

impl Query<GetContestedResourcesRequest> for VotePollsByDocumentTypeQuery

source§

impl Query<GetDataContractsRequest> for Vec<Identifier>

source§

impl Query<GetEpochsInfoRequest> for EpochIndex

source§

impl Query<GetIdentityContractNonceRequest> for (Identifier, Identifier)

source§

impl Query<GetPathElementsRequest> for KeysInPath

source§

impl Query<GetProtocolVersionUpgradeStateRequest> for ()

source§

impl Query<GetProtocolVersionUpgradeVoteStatusRequest> for Option<ProTxHash>

Convenience method that allows direct use of a ProTxHash

source§

impl Query<GetProtocolVersionUpgradeVoteStatusRequest> for ProTxHash

Convenience method that allows direct use of a ProTxHash

source§

impl Query<GetTotalCreditsInPlatformRequest> for NoParamQuery

source§

impl Query<GetVotePollsByEndDateRequest> for VotePollsByEndDateDriveQuery

Implementors§

source§

impl Query<IdentityRequest> for Identifier

source§

impl Query<IdentityRequest> for PublicKeyHash

source§

impl Query<GetContestedResourceIdentityVotesRequest> for LimitQuery<VoteQuery>

source§

impl Query<GetContestedResourceVoteStateRequest> for LimitQuery<ContestedDocumentVotePollDriveQuery>

source§

impl Query<GetContestedResourceVotersForIdentityRequest> for LimitQuery<GetContestedResourceVotersForIdentityRequest>

source§

impl Query<GetContestedResourcesRequest> for LimitQuery<GetContestedResourcesRequest>

source§

impl Query<GetDataContractHistoryRequest> for LimitQuery<(Identifier, u64)>

source§

impl Query<GetDataContractRequest> for Identifier

source§

impl Query<GetEpochsInfoRequest> for EpochQuery

source§

impl Query<GetIdentityBalanceAndRevisionRequest> for Identifier

source§

impl Query<GetIdentityBalanceRequest> for Identifier

source§

impl Query<GetIdentityKeysRequest> for Identifier

source§

impl Query<GetIdentityNonceRequest> for Identifier

source§

impl Query<GetPrefundedSpecializedBalanceRequest> for Identifier

source§

impl Query<GetProtocolVersionUpgradeVoteStatusRequest> for LimitQuery<Option<ProTxHash>>

source§

impl Query<GetProtocolVersionUpgradeVoteStatusRequest> for LimitQuery<ProTxHash>

Convenience method that allows direct use of a ProTxHash

source§

impl<'a> Query<DocumentQuery> for DriveDocumentQuery<'a>

source§

impl<E: Into<EpochQuery> + Clone + Debug + Send> Query<GetEpochsInfoRequest> for LimitQuery<E>

source§

impl<T> Query<T> for T
where T: TransportRequest + Sized + Send + Sync + Clone + Debug, T::Response: Send + Sync + Debug,