mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-04-06 21:14:03 -04:00
Fix API access for VeilidComponentGuard
This commit is contained in:
parent
044a9fa5e6
commit
3544cdf62b
@ -2,7 +2,7 @@ use super::*;
|
||||
|
||||
impl_veilid_log_facility!("registry");
|
||||
|
||||
pub trait AsAnyArcSendSync {
|
||||
pub(crate) trait AsAnyArcSendSync {
|
||||
fn as_any_arc_send_sync(self: Arc<Self>) -> Arc<dyn core::any::Any + Send + Sync>;
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ impl<T: Send + Sync + 'static> AsAnyArcSendSync for T {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait VeilidComponent:
|
||||
pub(crate) trait VeilidComponent:
|
||||
AsAnyArcSendSync + VeilidComponentRegistryAccessor + core::fmt::Debug
|
||||
{
|
||||
fn name(&self) -> &'static str;
|
||||
@ -22,7 +22,7 @@ pub trait VeilidComponent:
|
||||
fn terminate(&self) -> PinBoxFuture<'_, ()>;
|
||||
}
|
||||
|
||||
pub trait VeilidComponentRegistryAccessor {
|
||||
pub(crate) trait VeilidComponentRegistryAccessor {
|
||||
fn registry(&self) -> VeilidComponentRegistry;
|
||||
|
||||
fn config(&self) -> VeilidConfig {
|
||||
@ -34,25 +34,19 @@ pub trait VeilidComponentRegistryAccessor {
|
||||
fn event_bus(&self) -> EventBus {
|
||||
self.registry().event_bus.clone()
|
||||
}
|
||||
fn namespace(&self) -> &'static str {
|
||||
self.registry().namespace()
|
||||
}
|
||||
fn program_name(&self) -> &'static str {
|
||||
self.registry().program_name()
|
||||
}
|
||||
fn log_key(&self) -> &'static str {
|
||||
self.registry().log_key()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct VeilidComponentGuard<'a, T: VeilidComponent + Send + Sync + 'static> {
|
||||
pub struct VeilidComponentGuard<'a, T: Send + Sync + 'static> {
|
||||
component: Arc<T>,
|
||||
_phantom: core::marker::PhantomData<&'a T>,
|
||||
}
|
||||
|
||||
impl<T> core::ops::Deref for VeilidComponentGuard<'_, T>
|
||||
where
|
||||
T: VeilidComponent + Send + Sync + 'static,
|
||||
T: Send + Sync + 'static,
|
||||
{
|
||||
type Target = T;
|
||||
|
||||
@ -69,7 +63,7 @@ struct VeilidComponentRegistryInner {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct VeilidComponentRegistry {
|
||||
pub(crate) struct VeilidComponentRegistry {
|
||||
inner: Arc<Mutex<VeilidComponentRegistryInner>>,
|
||||
config: VeilidConfig,
|
||||
namespace: &'static str,
|
||||
@ -106,6 +100,7 @@ impl VeilidComponentRegistry {
|
||||
inner.mock = true;
|
||||
}
|
||||
|
||||
#[expect(dead_code)]
|
||||
pub fn namespace(&self) -> &'static str {
|
||||
self.namespace
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ impl VeilidCoreContext {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub trait RegisteredComponents {
|
||||
pub(crate) trait RegisteredComponents {
|
||||
fn protected_store<'a>(&self) -> VeilidComponentGuard<'a, ProtectedStore>;
|
||||
fn crypto<'a>(&self) -> VeilidComponentGuard<'a, Crypto>;
|
||||
fn table_store<'a>(&self) -> VeilidComponentGuard<'a, TableStore>;
|
||||
|
@ -120,7 +120,7 @@ impl Crypto {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
pub(crate) fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
Self {
|
||||
registry: registry.clone(),
|
||||
inner: Mutex::new(Self::new_inner()),
|
||||
|
@ -54,7 +54,7 @@ pub struct CryptoSystemNONE {
|
||||
}
|
||||
|
||||
impl CryptoSystemNONE {
|
||||
pub fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
pub(crate) fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
Self { registry }
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ pub struct CryptoSystemVLD0 {
|
||||
|
||||
impl CryptoSystemVLD0 {
|
||||
#[must_use]
|
||||
pub fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
pub(crate) fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
Self { registry }
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ impl BlockStore {
|
||||
fn new_inner() -> BlockStoreInner {
|
||||
BlockStoreInner {}
|
||||
}
|
||||
pub fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
pub(crate) fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
Self {
|
||||
registry,
|
||||
inner: Mutex::new(Self::new_inner()),
|
||||
|
@ -30,7 +30,7 @@ impl ProtectedStore {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
pub(crate) fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
Self {
|
||||
registry,
|
||||
inner: Mutex::new(Self::new_inner()),
|
||||
|
@ -25,7 +25,7 @@ impl BlockStore {
|
||||
fn new_inner() -> BlockStoreInner {
|
||||
BlockStoreInner {}
|
||||
}
|
||||
pub fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
pub(crate) fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
Self {
|
||||
registry,
|
||||
inner: Mutex::new(Self::new_inner()),
|
||||
|
@ -14,7 +14,7 @@ pub struct ProtectedStore {
|
||||
impl_veilid_component!(ProtectedStore);
|
||||
|
||||
impl ProtectedStore {
|
||||
pub fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
pub(crate) fn new(registry: VeilidComponentRegistry) -> Self {
|
||||
Self { registry }
|
||||
}
|
||||
|
||||
|
@ -59,13 +59,15 @@ mod wasm_helpers;
|
||||
|
||||
pub(crate) use self::component::*;
|
||||
pub(crate) use self::core_context::RegisteredComponents;
|
||||
pub(crate) use self::stats_accounting::*;
|
||||
|
||||
pub use self::component::VeilidComponentGuard;
|
||||
pub use self::core_context::{api_startup, api_startup_config, api_startup_json, UpdateCallback};
|
||||
pub use self::logging::{
|
||||
ApiTracingLayer, FmtStripFields, VeilidLayerFilter, VeilidLayerLogKeyFilter,
|
||||
DEFAULT_LOG_FACILITIES_ENABLED_LIST, DEFAULT_LOG_FACILITIES_IGNORE_LIST,
|
||||
DURATION_LOG_FACILITIES, FLAME_LOG_FACILITIES_IGNORE_LIST, VEILID_LOG_KEY_FIELD,
|
||||
};
|
||||
pub(crate) use self::stats_accounting::*;
|
||||
pub use self::veilid_api::*;
|
||||
pub use self::veilid_config::*;
|
||||
pub use veilid_tools as tools;
|
||||
|
Loading…
x
Reference in New Issue
Block a user