Skip to main content

CredentialsBundle

Struct CredentialsBundle 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn telegram_account(&self, instance: &str) -> Option<&TelegramAccount>

Phase 93.9.b — daemon-owned Telegram typed accessor.

Source

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.

Source

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.

Source

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.

Source

pub fn email_store(&self) -> Arc<EmailCredentialStore>

Phase 93.9.f — typed Arc<EmailCredentialStore> accessor.

Source

pub fn whatsapp_store(&self) -> Arc<WhatsappCredentialStore>

Phase 93.9.f — typed Arc<WhatsappCredentialStore> accessor.

Source

pub fn telegram_store(&self) -> Arc<TelegramCredentialStore>

Phase 93.9.f — typed Arc<TelegramCredentialStore> accessor.

Source

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")].

Trait Implementations§

Source§

impl Debug for CredentialsBundle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more