pub struct CredentialsBundle {
pub resolver: Arc<AgentCredentialResolver>,
pub breakers: Arc<BreakerRegistry>,
pub warnings: Vec<String>,
pub stores_v2: DashMap<String, Arc<dyn GenericCredentialStore>>,
/* private fields */
}Expand description
Bundle returned by build_credentials — holds every store plus
the resolver. main.rs hands this to plugins / tools.
Fields§
§resolver: Arc<AgentCredentialResolver>§breakers: Arc<BreakerRegistry>Per-(channel, instance) circuit breakers shared with plugin
tools. Created with default config; failure on one account
never trips another.
warnings: Vec<String>§stores_v2: DashMap<String, Arc<dyn GenericCredentialStore>>Phase 93.7 — opt-in plugin-contributed credential stores
keyed by manifest.plugin.id. Empty at boot; populated by
the init-loop after each plugin’s init(ctx) succeeds via
NexoPlugin::credential_store(). Phase 93.9.a hides the
typed stores field; .b-.f migrate the remaining runtime
consumers to walk this map exclusively.
Implementations§
Source§impl CredentialsBundle
impl CredentialsBundle
Sourcepub fn empty_for_testing() -> Self
pub fn empty_for_testing() -> Self
Phase 93.9.f — public test-only constructor. External
crates (crates/poller, crates/setup, integration
tests) used to build the bundle directly by initialising
every field; now that Self::stores is pub(crate),
this helper hands back an empty bundle suitable for fixtures
without exposing the typed CredentialStores shape.
Sourcepub fn google_account(&self, id: &str) -> Option<&GoogleAccount>
pub fn google_account(&self, id: &str) -> Option<&GoogleAccount>
Phase 93.9.b — typed-account accessor for the daemon-owned
Google channel. Plugin extraction is deferred; runtime
consumers (gmail / google-calendar pollers, setup wizard
services) use this method instead of touching
bundle.stores.google.account(...) directly. Phase 93.9.f
flips stores to pub(crate) once every external caller
has migrated to these accessors.
Sourcepub fn google_account_for_agent(&self, agent_id: &str) -> Option<&GoogleAccount>
pub fn google_account_for_agent(&self, agent_id: &str) -> Option<&GoogleAccount>
Same shape as Self::google_account but keyed by
agent_id — Google enforces a 1:1 account-to-agent rule, so
gmail-poller jobs that only know the agent can still recover
the account.
Sourcepub fn whatsapp_account(&self, instance: &str) -> Option<&WhatsappAccount>
pub fn whatsapp_account(&self, instance: &str) -> Option<&WhatsappAccount>
Phase 93.9.b — daemon-owned WhatsApp typed accessor. The
subprocess plugin contributes a RemoteCredentialStore to
stores_v2 but legacy in-process consumers (gauntlet,
observability surface) still need typed access.
Sourcepub fn telegram_account(&self, instance: &str) -> Option<&TelegramAccount>
pub fn telegram_account(&self, instance: &str) -> Option<&TelegramAccount>
Phase 93.9.b — daemon-owned Telegram typed accessor.
Sourcepub fn email_account(&self, instance: &str) -> Option<&EmailAccount>
pub fn email_account(&self, instance: &str) -> Option<&EmailAccount>
Phase 93.9.b — daemon-owned Email typed accessor. Wizard +
poller migrators in 93.9.c-e replace direct
bundle.stores.email.account() calls with this method.
Sourcepub fn google_refresh_lock(
&self,
handle: &CredentialHandle,
) -> Option<Arc<Mutex<()>>>
pub fn google_refresh_lock( &self, handle: &CredentialHandle, ) -> Option<Arc<Mutex<()>>>
Phase 93.9.b — refresh-lock accessor for Google’s
concurrent-refresh guard. Hides the typed
stores.google.refresh_lock(...) call.
Sourcepub fn google_store(&self) -> Arc<GoogleCredentialStore> ⓘ
pub fn google_store(&self) -> Arc<GoogleCredentialStore> ⓘ
Phase 93.9.f — typed Arc<GoogleCredentialStore> accessor
for plugin constructors that need the whole store (not a
single account). Hides the aggregate CredentialStores
shape from external code while preserving the typed-Arc
surface daemon-internal plugins still rely on.
Sourcepub fn email_store(&self) -> Arc<EmailCredentialStore> ⓘ
pub fn email_store(&self) -> Arc<EmailCredentialStore> ⓘ
Phase 93.9.f — typed Arc<EmailCredentialStore> accessor.
Sourcepub fn whatsapp_store(&self) -> Arc<WhatsappCredentialStore> ⓘ
pub fn whatsapp_store(&self) -> Arc<WhatsappCredentialStore> ⓘ
Phase 93.9.f — typed Arc<WhatsappCredentialStore> accessor.
Sourcepub fn telegram_store(&self) -> Arc<TelegramCredentialStore> ⓘ
pub fn telegram_store(&self) -> Arc<TelegramCredentialStore> ⓘ
Phase 93.9.f — typed Arc<TelegramCredentialStore> accessor.
Sourcepub fn account_count(&self, channel: Channel) -> usize
pub fn account_count(&self, channel: Channel) -> usize
Account count for channel. Reads from stores_v2 first
(plugin-contributed GenericCredentialStore); falls back to
the internal typed CredentialStores so boot-time consumers
see correct counts before plugin init lands.
stores_v2.list() is async; this accessor blocks via
tokio::task::block_in_place. Callers must be on a
multi-thread Tokio runtime. The daemon’s #[tokio::main]
satisfies this; unit tests should use
#[tokio::test(flavor = "multi_thread")].