Setting verse key by text
Add the ability to set a very key by text Make the main.rs iterate random verses in John 3
This commit is contained in:
+3
-1
@@ -5,14 +5,16 @@ pub mod ffi {
|
||||
include!("sword_rs/src/cxx/module.h");
|
||||
|
||||
type Mgr;
|
||||
type Module;
|
||||
|
||||
fn new_mgr() -> UniquePtr<Mgr>;
|
||||
fn new_mgr_with_path(path: &String) -> UniquePtr<Mgr>;
|
||||
fn get_modules(self: &Mgr) -> Vec<String>;
|
||||
fn get_module(self: Pin<&mut Mgr>, name: &String) -> UniquePtr<Module>;
|
||||
|
||||
type Module;
|
||||
|
||||
fn get_name(self: &Module) -> String;
|
||||
fn set_key_text(self: Pin<&mut Module>, key_text: &String) -> ();
|
||||
fn strip_text(self: Pin<&mut Module>) -> String;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,8 @@ class Module {
|
||||
(const char*) this->module->stripText()
|
||||
);
|
||||
}
|
||||
|
||||
void set_key_text(const rust::String& keyText) {
|
||||
this->module->setKeyText(std::string(keyText).c_str());
|
||||
}
|
||||
};
|
||||
|
||||
+9
-1
@@ -1,3 +1,4 @@
|
||||
use rand::Rng;
|
||||
use sword_rs::mgr::Mgr;
|
||||
|
||||
fn main() {
|
||||
@@ -5,6 +6,13 @@ fn main() {
|
||||
for mod_name in mgr.get_modules() {
|
||||
let mut module = mgr.get_module(&mod_name);
|
||||
println!("Module: {}", module.get_name());
|
||||
println!("Text: {}", module.strip_text());
|
||||
let random_number: i32 = rand::rng().gen_range(1..=20);
|
||||
let random_number_str = format!("John.3.{}", random_number);
|
||||
module.set_key_text(&random_number_str);
|
||||
println!(
|
||||
"Text John 3:{} is \"{}\"",
|
||||
random_number,
|
||||
module.strip_text()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,8 @@ impl Module {
|
||||
pub fn strip_text(&mut self) -> String {
|
||||
self.module.pin_mut().strip_text()
|
||||
}
|
||||
|
||||
pub fn set_key_text(&mut self, key_text: &String) {
|
||||
self.module.pin_mut().set_key_text(key_text);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user