deltachat::accounts

Struct Accounts

source
pub struct Accounts {
    dir: PathBuf,
    config: Config,
    accounts: BTreeMap<u32, Context>,
    events: Events,
    pub(crate) stockstrings: StockStrings,
    push_subscriber: PushSubscriber,
}
Expand description

Account manager, that can handle multiple accounts in a single place.

Fields§

§dir: PathBuf§config: Config§accounts: BTreeMap<u32, Context>

Map from account ID to the account.

§events: Events

Event channel to emit account manager errors.

§stockstrings: StockStrings

Stock string translations shared by all created contexts.

This way changing a translation for one context automatically changes it for all other contexts.

§push_subscriber: PushSubscriber

Push notification subscriber shared between accounts.

Implementations§

source§

impl Accounts

source

pub async fn set_stock_translation( &self, id: StockMessage, stockstring: String, ) -> Result<()>

Set the stock string for the StockMessage.

source§

impl Accounts

source

pub async fn new(dir: PathBuf, writable: bool) -> Result<Self>

Loads or creates an accounts folder at the given dir.

source

async fn create(dir: &Path) -> Result<()>

Creates a new default structure.

source

async fn open(dir: PathBuf, writable: bool) -> Result<Self>

Opens an existing accounts structure. Will error if the folder doesn’t exist, no account exists and no config exists.

source

pub fn get_account(&self, id: u32) -> Option<Context>

Returns an account by its id:

source

pub fn get_selected_account(&self) -> Option<Context>

Returns the currently selected account.

source

pub fn get_selected_account_id(&self) -> Option<u32>

Returns the currently selected account’s id or None if no account is selected.

source

pub async fn select_account(&mut self, id: u32) -> Result<()>

Selects the given account.

source

pub async fn add_account(&mut self) -> Result<u32>

Adds a new account and opens it.

Returns account ID.

source

pub async fn add_closed_account(&mut self) -> Result<u32>

Adds a new closed account.

source

pub async fn remove_account(&mut self, id: u32) -> Result<()>

Removes an account.

source

pub async fn migrate_account(&mut self, dbfile: PathBuf) -> Result<u32>

Migrates an existing account into this structure.

Returns the ID of new account.

source

pub fn get_all(&self) -> Vec<u32>

Get a list of all account ids.

source

pub async fn start_io(&mut self)

Starts background tasks such as IMAP and SMTP loops for all accounts.

source

pub async fn stop_io(&self)

Stops background tasks for all accounts.

source

pub async fn maybe_network(&self)

Notifies all accounts that the network may have become available.

source

pub async fn maybe_network_lost(&self)

Notifies all accounts that the network connection may have been lost.

source

async fn background_fetch_no_timeout(accounts: Vec<Context>, events: Events)

Performs a background fetch for all accounts in parallel.

This is an auxiliary function and not part of public API. Use Accounts::background_fetch instead.

source

async fn background_fetch_with_timeout( accounts: Vec<Context>, events: Events, timeout: Duration, )

Auxiliary function for Accounts::background_fetch.

source

pub fn background_fetch(&self, timeout: Duration) -> impl Future<Output = ()>

Performs a background fetch for all accounts in parallel with a timeout.

The AccountsBackgroundFetchDone event is emitted at the end, process all events until you get this one and you can safely return to the background without forgetting to create notifications caused by timing race conditions.

Returns a future that resolves when background fetch is done, but does not capture &self.

source

pub fn emit_event(&self, event: EventType)

Emits a single event.

source

pub fn get_event_emitter(&self) -> EventEmitter

Returns event emitter.

source

pub async fn set_push_device_token(&self, token: &str) -> Result<()>

Sets notification token for Apple Push Notification service.

Trait Implementations§

source§

impl Debug for Accounts

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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.

§

impl<T> Instrument for T

§

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

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

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T