87 lines
2.3 KiB
Rust
87 lines
2.3 KiB
Rust
use crate::cxx::ffi;
|
|
use cxx::UniquePtr;
|
|
|
|
#[derive(PartialEq)]
|
|
pub enum Type {
|
|
Unknown,
|
|
BiblicalTexts,
|
|
Commentaries,
|
|
DailyDevotional,
|
|
GenericBooks,
|
|
Lexicons,
|
|
}
|
|
|
|
impl Type {
|
|
pub fn new(type_str: &String) -> Self {
|
|
match type_str.as_str() {
|
|
"Biblical Texts" => Type::BiblicalTexts,
|
|
"Commentaries" => Type::Commentaries,
|
|
"Daily Devotional" => Type::DailyDevotional,
|
|
"Generic Books" => Type::GenericBooks,
|
|
"Lexicons / Dictionaries" => Type::Lexicons,
|
|
_ => Type::Unknown,
|
|
}
|
|
}
|
|
|
|
pub fn get_name(&self) -> String {
|
|
match self {
|
|
Type::BiblicalTexts => String::from("Biblical Texts"),
|
|
Type::Commentaries => String::from("Commentaries"),
|
|
Type::DailyDevotional => String::from("Daily Devotional"),
|
|
Type::GenericBooks => String::from("Generic Books"),
|
|
Type::Lexicons => String::from("Lexicons / Dictionaries"),
|
|
Type::Unknown => String::from("Unknown"),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub struct Module {
|
|
module: UniquePtr<ffi::Module>,
|
|
}
|
|
|
|
impl Module {
|
|
pub fn new(module: UniquePtr<ffi::Module>) -> Self {
|
|
Self { module: module }
|
|
}
|
|
|
|
pub fn decrement(&mut self) {
|
|
self.module.pin_mut().decrement();
|
|
}
|
|
|
|
pub fn get_name(&self) -> String {
|
|
self.module.get_name()
|
|
}
|
|
|
|
pub fn get_type(&self) -> Type {
|
|
// This line I will use to see what the C++ library returns
|
|
// for all module types.
|
|
// You can also check swmgr.cpp for the list
|
|
// println!("{}", self.module.get_type());
|
|
Type::new(&self.module.get_type())
|
|
}
|
|
|
|
pub fn increment(&mut self) {
|
|
self.module.pin_mut().increment();
|
|
}
|
|
|
|
pub fn is_skip_consecutive_links(&self) -> bool {
|
|
self.module.is_skip_consecutive_links()
|
|
}
|
|
|
|
pub fn render_text(&mut self) -> String {
|
|
self.module.pin_mut().render_text()
|
|
}
|
|
|
|
pub fn set_key_text(&mut self, key_text: &String) {
|
|
self.module.pin_mut().set_key_text(key_text);
|
|
}
|
|
|
|
pub fn set_skip_consecutive_links(&mut self, skip: bool) {
|
|
self.module.pin_mut().set_skip_consecutive_links(skip);
|
|
}
|
|
|
|
pub fn strip_text(&mut self) -> String {
|
|
self.module.pin_mut().strip_text()
|
|
}
|
|
}
|