pub fn create_cargo_lib(
    lss: Box<dyn LocalSecureStorage>,
    cfg: CargoConfig
) -> Result<Arc<Mutex<CargoLib>>, ClientCreationError>
Expand description

CargoLib initializer which is the main part of Cargo public API. All functionalities are exposed to application side through this structure.

Underlying structure is created only once, subsequent call will return handle to the same structure.

It requires the following arguments:

  • lss: some type implementing LocalSecureStorage trait. It is usually provided by the native to a target platform language.
  • cfg: CargoConfig structure with config variables (logger, endpoints, etc.)
struct TestLss{};

impl LocalSecureStorage for TestLss {
// ...implementation here
}

let lss = Box::new(TestLss{});


let cfg = CargoConfig{
    logger_config: LoggerConfig {
        use_logger: true,
        log_level: Level::TRACE,
        log_use_ansi: false,
        log_file_path: PathBuf::from("cargo_lib_log"),
        log_file_rotate_directory: PathBuf::from(".".to_owned()),
        log_file_enabled: true,
        #[cfg(any(target_os = "macos", target_os = "ios"))]
        oslog_category: None,
        #[cfg(any(target_os = "macos", target_os = "ios"))]
        oslog_subsystem: None,
    },
    fsa_config: FoundationStorageApiConfig {
        evs_url: "some_url".to_owned(),
    },
    catlib_config: CatlibConfig {
        gql_url: url::Url::parse("http://127.0.0.1/graphql/").unwrap().try_into().unwrap(),
    },
    multidevice_state: UserConfig {
        redis_config: url::Url::parse("redis://127.0.0.1/0").unwrap().try_into().unwrap()
    }
};

let cargo_lib = create_cargo_lib(lss, cfg);