pub struct TrqlClient { /* private fields */ }Expand description
Transport-agnostic Trust Registry query client.
Holds one TrqlTransport and the registry’s DID (the recipient stamped
on every request — the registry rejects documents addressed to anyone
else). Swapping HTTPS for DIDComm or TSP changes only the transport handed
to TrqlClient::new.
Implementations§
Source§impl TrqlClient
impl TrqlClient
Sourcepub fn new(
transport: Arc<dyn TrqlTransport>,
registry_did: impl Into<String>,
) -> Self
pub fn new( transport: Arc<dyn TrqlTransport>, registry_did: impl Into<String>, ) -> Self
A client that queries the registry identified by registry_did over
transport.
Sourcepub fn with_client_did(self, did: impl Into<String>) -> Self
pub fn with_client_did(self, did: impl Into<String>) -> Self
Set the in-band issuer on outbound documents. Optional over HTTPS
(the registry treats queries as anonymous reads); DIDComm and TSP
authenticate the sender at the transport layer regardless.
Sourcepub fn referred_by(self, origin_did: impl Into<String>) -> Self
pub fn referred_by(self, origin_did: impl Into<String>) -> Self
Record that this client reached the registry by following a
crate::registry_referral in origin_did’s document, and hold every
answer to that provenance.
This is step 5 of DID_SERVICE_DISCOVERY.md §4 — closing the loop —
made structural instead of advisory. With it set, an answer whose
authority_id is anything other than origin_did is rejected as
TrqlError::ReferralNotClosed rather than returned.
A referral is a self-assertion: anyone can publish a DID document
naming any registry, so a followed referral establishes where to ask
and nothing about the answer. Authority flows registry → subject, and
only the registry answering for origin_did completes that direction.
let mut doc = resolve(vtc_did).await?;
let client = match registry_referral(&doc) {
Some(registry) => {
doc = resolve(®istry).await?; // one hop
TrqlClient::new(transport, registry).referred_by(vtc_did)
}
None => TrqlClient::new(transport, registry_did),
};Ask whether entity is authorized by authority for action on
resource (registry/authorization/0.1).
A registry with no matching record answers authorized: false — absence
is a denial, not an error.
Sourcepub async fn recognition(
&self,
query: TrqpQuery,
) -> Result<RecognitionResponse, TrqlError>
pub async fn recognition( &self, query: TrqpQuery, ) -> Result<RecognitionResponse, TrqlError>
Ask whether entity is recognized by authority for action on
resource (registry/recognition/0.1).