init_rust_components/lib.rs
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 */
5
6#[cfg(not(feature = "keydb"))]
7use nss::ensure_initialized as ensure_nss_initialized;
8#[cfg(feature = "keydb")]
9use nss::ensure_initialized_with_profile_dir as ensure_nss_initialized_with_profile_dir;
10
11uniffi::setup_scaffolding!();
12
13/// Global initialization routines for Rust components. Must be called before any other calls to
14/// Rust components.
15///
16/// For adding additional initialization code: Note that this function is called very early in the
17/// app lifetime and therefore affects the startup time. Only the most necessary things should be
18/// done here.
19#[cfg(not(feature = "keydb"))]
20#[uniffi::export]
21pub fn initialize() {
22 ensure_nss_initialized();
23}
24
25/// Global initialization routines for Rust components, when `logins/keydb` feature is activated. Must be
26/// called before any other calls to Rust components.
27///
28/// Receives the path to the profile directory.
29///
30/// For adding additional initialization code: Note that this function is called very early in the
31/// app lifetime and therefore affects the startup time. Only the most necessary things should be
32/// done here.
33#[cfg(feature = "keydb")]
34#[uniffi::export]
35pub fn initialize(profile_path: String) {
36 ensure_nss_initialized_with_profile_dir(profile_path);
37}