pub trait ScrapingService: Send + Sync {
// Required methods
fn execute<'life0, 'async_trait>(
&'life0 self,
input: ServiceInput,
) -> Pin<Box<dyn Future<Output = Result<ServiceOutput>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn name(&self) -> &'static str;
}Expand description
Primary port: ScrapingService trait
All scraping modules (HTTP, browser, JavaScript rendering) implement this trait.
Uses async_trait for dyn compatibility with service registry.
§Example Implementation
use stygian_graph::ports::{ScrapingService, ServiceInput, ServiceOutput};
use stygian_graph::error::Result;
use async_trait::async_trait;
use serde_json::json;
struct MyService;
#[async_trait]
impl ScrapingService for MyService {
async fn execute(&self, input: ServiceInput) -> Result<ServiceOutput> {
Ok(ServiceOutput {
data: format!("Scraped: {}", input.url),
metadata: json!({"status": "ok"}),
})
}
fn name(&self) -> &'static str {
"my-service"
}
}Required Methods§
Sourcefn execute<'life0, 'async_trait>(
&'life0 self,
input: ServiceInput,
) -> Pin<Box<dyn Future<Output = Result<ServiceOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
input: ServiceInput,
) -> Pin<Box<dyn Future<Output = Result<ServiceOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the scraping operation
§Arguments
input- Service input containing URL and parameters
§Returns
Ok(ServiceOutput)- Successful scraping resultErr(StygianError)- Service error, timeout, or network failure
§Example
let input = ServiceInput {
url: "https://example.com".to_string(),
params: json!({}),
};
let output = service.execute(input).await.unwrap();
println!("Data: {}", output.data);