MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / try_resolve

Method try_resolve

crates/client-api/src/util.rs:97–105  ·  view source on GitHub ↗

Resolve this [`NameOrIdentity`]. If `self` is a [`NameOrIdentity::Identity`], the inner [`Identity`] is returned directly. Otherwise, if `self` is a [`NameOrIdentity::Name`], the [`Identity`] is looked up by that name in the SpacetimeDB DNS and returned. Errors are returned if the DNS lookup fails. An `Ok` result is itself a [`Result`], which is `Err(DatabaseName)` if the given [`NameOrIdentit

(
        &self,
        ctx: &(impl ControlStateReadAccess + ?Sized),
    )

Source from the content-addressed store, hash-verified

95 /// given [`NameOrIdentity::Name`] is not registered in the SpacetimeDB DNS,
96 /// i.e. no corresponding [`Identity`] exists.
97 pub async fn try_resolve(
98 &self,
99 ctx: &(impl ControlStateReadAccess + ?Sized),
100 ) -> anyhow::Result<Result<Identity, &DatabaseName>> {
101 Ok(match self {
102 Self::Identity(identity) => Ok(Identity::from(*identity)),
103 Self::Name(name) => ctx.lookup_database_identity(name.as_ref()).await?.ok_or(name),
104 })
105 }
106
107 /// A variant of [`Self::try_resolve()`] which maps to a 404 (Not Found)
108 /// response if `self` is a [`NameOrIdentity::Name`] for which no

Callers 3

resolveMethod · 0.80
publishFunction · 0.80

Calls 3

OkFunction · 0.50
as_refMethod · 0.45

Tested by

no test coverage detected