i18n_provider_sqlite3/lib.rs
1// This file is part of `i18n_provider_sqlite3-rizzen-yazston` crate. For the terms of use, please see the file
2// called `LICENSE-BSD-3-Clause` at the top level of the `i18n_provider_sqlite3-rizzen-yazston` crate.
3
4//! Welcome to the **`i18n_provider_sqlite3`** crate of the *Internationalisation* (i18n) project.
5//!
6//! This crate consists of five modules:
7//!
8//! * [`error`]: Contains the error enum for the Sqlite3 provider,
9//!
10//! * [`provider`]: The provider implementation using Sqlite3 for the data store.
11//!
12//! # Features
13//!
14//! Available features for `i18n_provider_sqlite3` crate:
15//!
16//! * `logging`: To provide some logging information.
17//!
18//! * `sync`: Allow for rust's concurrency capabilities to be used. Use of `Arc` and `Mutex` instead `Rc` and
19//! `RefCell`.
20//!
21//! # Modules
22//!
23//! ## `provider`: Sqlite3 provider for localisation strings.
24//!
25//! This crate implements [`LocalisationProviderTrait`] using Sqlite3 as the data store for localisation strings. As a
26//! directory path is used at the time of creating a `LocalisationProviderSqlite3` instance, it means that an
27//! application can have multiple data stores for both application localisation strings, and also for data packages'
28//! localisation strings.
29//!
30//! ### Examples
31//!
32//! ```
33//! use i18n_provider_sqlite3::LocalisationProviderSqlite3;
34//! use i18n_provider::LocalisationProviderTrait;
35//! use i18n_utility::LanguageTagRegistry;
36//! use std::rc::Rc;
37//! use std::error::Error;
38//!
39//! fn main() -> Result<(), Box<dyn Error>> {
40//! let path = "./l10n/";
41//! let registry = Rc::new( LanguageTagRegistry::new() );
42//! let tag = registry.tag( "en" )?;
43//! let provider = LocalisationProviderSqlite3::try_new(
44//! path,
45//! ®istry,
46//! false
47//! )?;
48//! let strings = provider.strings(
49//! "i18n_provider_sqlite3",
50//! "path_conversion",
51//! &tag,
52//! )?;
53//! assert_eq!( strings.len(), 1, "There should be 1 string." );
54//! assert_eq!( strings[ 0 ].0.as_str(), "Conversion to {`PathBuf`} error.", "Not correct string." );
55//! assert_eq!( strings[ 0 ].1.as_str(), "en-ZA", "Must be en-ZA." );
56//! Ok( () )
57//! }
58//! ```
59//!
60//! # Localisation Sqlite3 templates
61//!
62//! Can find the templates `all_in_one.sqlite3` and component `application.sqlite3` for the application in the `l10n`
63//! directory.
64
65#[cfg(doc)]
66use std::sync::{Arc, Mutex};
67
68#[cfg(doc)]
69use std::rc::Rc;
70
71#[cfg(doc)]
72use std::cell::RefCell;
73
74#[cfg(doc)]
75use i18n_utility::TaggedString;
76
77#[cfg(doc)]
78use i18n_provider::LocalisationProviderTrait;
79
80pub mod provider;
81pub use provider::*;
82pub mod error;
83pub use error::*;