Now with skipping consecutive links

This commit is contained in:
Greg Hellings
2025-02-25 15:45:58 -06:00
parent 93b2cb6447
commit fc904b33b3
5 changed files with 25 additions and 2 deletions
+2
View File
@@ -17,8 +17,10 @@ pub mod ffi {
fn decrement(self: Pin<&mut Module>);
fn get_name(self: &Module) -> String;
fn increment(self: Pin<&mut Module>);
fn is_skip_consecutive_links(self: &Module) -> bool;
fn render_text(self: Pin<&mut Module>) -> String;
fn set_key_text(self: Pin<&mut Module>, key_text: &String) -> ();
fn set_skip_consecutive_links(self: Pin<&mut Module>, skip: bool);
fn strip_text(self: Pin<&mut Module>) -> String;
}
}
+10 -2
View File
@@ -15,6 +15,10 @@ namespace sword_rs {
this->module->increment();
}
bool Module::is_skip_consecutive_links() const {
return this->module->isSkipConsecutiveLinks();
}
rust::String Module::render_text() {
return std::string(
(const char*) this->module->renderText()
@@ -22,8 +26,12 @@ namespace sword_rs {
}
void Module::set_key_text(const rust::String& keyText) {
this->module->setKeyText(std::string(keyText).c_str());
}
this->module->setKeyText(std::string(keyText).c_str());
}
void Module::set_skip_consecutive_links(bool skip) {
this->module->setSkipConsecutiveLinks(skip);
}
rust::String Module::strip_text() {
return std::string(
+4
View File
@@ -19,10 +19,14 @@ namespace sword_rs {
void increment();
bool is_skip_consecutive_links() const;
rust::String render_text();
void set_key_text(const rust::String& keyText);
void set_skip_consecutive_links(bool skip);
rust::String strip_text();
};
}
+1
View File
@@ -9,6 +9,7 @@ fn main() {
let random_number: i32 = rand::rng().random_range(1..=20);
let random_number_str = format!("John.3.{}", random_number);
module.set_key_text(&random_number_str);
module.set_skip_consecutive_links(true);
for i in 0..10 {
module.increment();
println!(
+8
View File
@@ -22,6 +22,10 @@ impl Module {
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()
}
@@ -30,6 +34,10 @@ impl Module {
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()
}