use crate::{ addressing::Address, database::{entry::Entry, UpEndConnection}, util::jobs::JobContainer, }; use anyhow::Result; use std::sync::{Arc, RwLock}; #[cfg(feature = "extractors-web")] pub mod web; pub trait Extractor { fn get( &self, address: &Address, job_container: Arc>, ) -> Result>; fn is_needed(&self, _address: &Address, _connection: &UpEndConnection) -> Result { Ok(true) } fn insert_info( &self, address: &Address, connection: &UpEndConnection, job_container: Arc>, ) -> Result<()> { if self.is_needed(address, connection)? { let entries = self.get(address, job_container)?; connection.transaction(|| { for entry in entries { connection.insert_entry(entry)?; } Ok(()) }) } else { Ok(()) } } }