open-feature 0.3.0

The official OpenFeature Rust SDK.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::sync::Arc;

use tokio::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};

use crate::HookWrapper;

#[derive(Clone, Default)]
pub struct GlobalHooks(Arc<RwLock<Vec<HookWrapper>>>);

impl GlobalHooks {
    pub async fn get(&self) -> RwLockReadGuard<'_, Vec<HookWrapper>> {
        self.0.read().await
    }

    pub async fn get_mut(&self) -> RwLockWriteGuard<'_, Vec<HookWrapper>> {
        self.0.write().await
    }
}