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),
)
| 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 |
no test coverage detected