wasmcloud_runtime/component/
identity.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use async_trait::async_trait;
use tracing::instrument;

use crate::capability::identity::{self, store};

use super::{Ctx, Handler};

/// `wasmcloud:identity/store` implementation
#[async_trait]
pub trait Identity {
    /// Handle `wasmcloud:identity/store.get`
    async fn get(
        &self,
        audience: &str,
    ) -> anyhow::Result<Result<Option<String>, identity::store::Error>>;
}

#[async_trait]
impl<H: Handler> store::Host for Ctx<H> {
    #[instrument(skip(self))]
    async fn get(
        &mut self,
        audience: String,
    ) -> anyhow::Result<Result<Option<String>, identity::store::Error>> {
        self.attach_parent_context();
        Identity::get(&self.handler, &audience).await
    }
}