Closed xvsfekcn closed 2 months ago
pub struct Yara {
data_dir: PathBuf,
// key = file_name
rule_source: Arc<RwLock<HashMap<String, Vec
let rules = compiler.build();
self.rules = Some(Box::leak(Box::new(rules)));
let scanner =Box::new(Scanner::new(self.rules.unwrap()));
self.scanner = Some(Arc::new(Mutex::new(*scanner)));
The Scanner
type can't be shared by multiple threads, but you can create one scanner per thread using the same Rules
. I'm not very familiar with the Tokio framework, so I can't provide detailed advice.
Here’s the translation of your text into English:
"I want to use Tokio and yara-x together to build a web server that provides malware scanning capabilities. How should I implement this? Are there any examples I can refer to? After using Box to work around the lifetime issues, I encountered the error: Rc cannot be sent between threads safely."
If you need further assistance or examples on how to implement this, feel free to ask! Some error:
Rc<yara_x::types::array::Array>
cannot be sent between threads safely,Rc<yara_x::types::structure::Struct>
cannot be sent between threads safely