felicia 0.5.1

service for accessing and sharing lists of bad actors
Documentation
use async_trait::async_trait;
use serde::Deserialize;

use crate::models::List;

pub mod file;
pub mod http;
pub mod manager;

#[derive(Debug, Deserialize)]
pub struct SourceList {
    sources: Vec<String>,
}

impl SourceList {
    pub fn new(sources: Vec<String>) -> Self {
        Self { sources }
    }

    pub fn sources(&self) -> &[String] {
        self.sources.as_ref()
    }
}

#[async_trait]
pub trait Source {
    type Error: std::error::Error;

    ///
    /// try to fetch the lists from this source
    ///
    async fn fetch(&self) -> Result<List, Self::Error>;

    ///
    /// lifetime in seconds until this source's cache is invalidated
    /// and has to be fetched again.
    ///
    fn lifetime(&self) -> u64;
}