diff --git a/veilid-core/src/component.rs b/veilid-core/src/component.rs index 380287a9..480f6b29 100644 --- a/veilid-core/src/component.rs +++ b/veilid-core/src/component.rs @@ -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) -> Arc; } @@ -12,7 +12,7 @@ impl 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, _phantom: core::marker::PhantomData<&'a T>, } impl 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>, 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 } diff --git a/veilid-core/src/core_context.rs b/veilid-core/src/core_context.rs index 7d1f7852..a50e0ecf 100644 --- a/veilid-core/src/core_context.rs +++ b/veilid-core/src/core_context.rs @@ -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>; diff --git a/veilid-core/src/crypto/mod.rs b/veilid-core/src/crypto/mod.rs index 49671d8d..207cae0d 100644 --- a/veilid-core/src/crypto/mod.rs +++ b/veilid-core/src/crypto/mod.rs @@ -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()), diff --git a/veilid-core/src/crypto/none/mod.rs b/veilid-core/src/crypto/none/mod.rs index abe17927..97f35d10 100644 --- a/veilid-core/src/crypto/none/mod.rs +++ b/veilid-core/src/crypto/none/mod.rs @@ -54,7 +54,7 @@ pub struct CryptoSystemNONE { } impl CryptoSystemNONE { - pub fn new(registry: VeilidComponentRegistry) -> Self { + pub(crate) fn new(registry: VeilidComponentRegistry) -> Self { Self { registry } } } diff --git a/veilid-core/src/crypto/vld0/mod.rs b/veilid-core/src/crypto/vld0/mod.rs index 0c0d9fc6..c7080a8e 100644 --- a/veilid-core/src/crypto/vld0/mod.rs +++ b/veilid-core/src/crypto/vld0/mod.rs @@ -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 } } } diff --git a/veilid-core/src/intf/native/block_store.rs b/veilid-core/src/intf/native/block_store.rs index 9e1b4fde..342417b9 100644 --- a/veilid-core/src/intf/native/block_store.rs +++ b/veilid-core/src/intf/native/block_store.rs @@ -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()), diff --git a/veilid-core/src/intf/native/protected_store.rs b/veilid-core/src/intf/native/protected_store.rs index fbce53b4..2ab97fc2 100644 --- a/veilid-core/src/intf/native/protected_store.rs +++ b/veilid-core/src/intf/native/protected_store.rs @@ -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()), diff --git a/veilid-core/src/intf/wasm/block_store.rs b/veilid-core/src/intf/wasm/block_store.rs index 9e1b4fde..342417b9 100644 --- a/veilid-core/src/intf/wasm/block_store.rs +++ b/veilid-core/src/intf/wasm/block_store.rs @@ -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()), diff --git a/veilid-core/src/intf/wasm/protected_store.rs b/veilid-core/src/intf/wasm/protected_store.rs index 25295ab1..c41cafb5 100644 --- a/veilid-core/src/intf/wasm/protected_store.rs +++ b/veilid-core/src/intf/wasm/protected_store.rs @@ -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 } } diff --git a/veilid-core/src/lib.rs b/veilid-core/src/lib.rs index 04e74320..b3e4f0aa 100644 --- a/veilid-core/src/lib.rs +++ b/veilid-core/src/lib.rs @@ -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;