Skip to main content

TargetSource

Trait TargetSource 

Source
pub trait TargetSource {
    // Required method
    fn targets(&self) -> Vec<Target>;

    // Provided method
    fn count(&self) -> usize { ... }
}
Expand description

Trait for any source of scan targets.

Implement this for custom target sources (APIs, databases, queues).

Required Methods§

Source

fn targets(&self) -> Vec<Target>

Get all targets.

Provided Methods§

Source

fn count(&self) -> usize

Number of targets.

Example:

use scantarget::{Target, TargetSource};

struct StaticSource(Vec<Target>);

impl TargetSource for StaticSource {
    fn targets(&self) -> Vec<Target> {
        self.0.clone()
    }
}

let source = StaticSource(vec!["https://example.com".parse::<Target>().unwrap()]);
assert_eq!(source.count(), 1);

Implementors§