pibtool_stock_data/data_source/
session_net_data_source.rs

1// SPDX-FileCopyrightText: Politik im Blick developers
2// SPDX-FileCopyrightText: Wolfgang Silbermayr <wolfgang@silbermayr.at>
3//
4// SPDX-License-Identifier: AGPL-3.0-or-later OR EUPL-1.2
5
6use std::collections::BTreeMap;
7
8use serde::{Deserialize, Serialize};
9use url::Url;
10
11use crate::DocumentKind;
12
13use super::DataSourceInfo;
14
15/// The SessionNet data source.
16#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
17pub struct SessionNetDataSource {
18    /// The entry url for the data source.
19    pub url: Url,
20
21    /// The name of the municipal council as declared in the SessionNet system.
22    pub municipal_council_name: String,
23
24    /// The kinds of documents provided by the data source.
25    pub contained_documents: BTreeMap<DocumentKind, SessionNetDocumentsConfiguration>,
26}
27
28impl DataSourceInfo for SessionNetDataSource {
29    fn is_download_supported(&self) -> bool {
30        true
31    }
32
33    fn provides_documents(&self, document_kind: DocumentKind) -> bool {
34        self.contained_documents.keys().any(|k| k == &document_kind)
35    }
36}
37
38/// Description for matching documents found in a SessionNet data source.
39#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
40pub struct SessionNetDocumentsConfiguration {
41    /// The regexes that match the specific document kind.
42    pub matching_label_regexes: Vec<String>,
43}