• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 6008856021

29 Aug 2023 06:44AM UTC coverage: 76.756% (-1.0%) from 77.736%
6008856021

push

github

web-flow
chore: Remove unused generic type parameter in `dozer-core` (#1929)

330 of 330 new or added lines in 38 files covered. (100.0%)

48977 of 63809 relevant lines covered (76.76%)

48470.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.56
/dozer-core/src/appsource.rs
1
use dozer_types::node::NodeHandle;
2

3
use crate::errors::ExecutionError;
4
use crate::errors::ExecutionError::{
5
    AmbiguousSourceIdentifier, AppSourceConnectionAlreadyExists, InvalidSourceIdentifier,
6
};
7
use crate::node::{PortHandle, SourceFactory};
8
use crate::Endpoint;
9
use std::collections::HashMap;
10

11
#[derive(Debug)]
×
12
pub struct AppSourceMappings {
13
    pub connection: String,
14
    /// From source name to output port handle.
15
    pub mappings: HashMap<String, PortHandle>,
16
}
17

18
impl AppSourceMappings {
19
    pub fn new(connection: String, mappings: HashMap<String, PortHandle>) -> Self {
679✔
20
        Self {
679✔
21
            connection,
679✔
22
            mappings,
679✔
23
        }
679✔
24
    }
679✔
25
}
26

27
#[derive(Debug, Default)]
676✔
28
pub struct AppSourceManager {
29
    pub(crate) sources: Vec<Box<dyn SourceFactory>>,
30
    pub(crate) mappings: Vec<AppSourceMappings>,
31
}
32

33
impl AppSourceManager {
34
    pub fn add(
679✔
35
        &mut self,
679✔
36
        source: Box<dyn SourceFactory>,
679✔
37
        mapping: AppSourceMappings,
679✔
38
    ) -> Result<(), ExecutionError> {
679✔
39
        if self
679✔
40
            .mappings
679✔
41
            .iter()
679✔
42
            .any(|existing_mapping| existing_mapping.connection == mapping.connection)
679✔
43
        {
×
44
            return Err(AppSourceConnectionAlreadyExists(mapping.connection));
1✔
45
        }
678✔
46

678✔
47
        self.sources.push(source);
678✔
48
        self.mappings.push(mapping);
678✔
49
        Ok(())
678✔
50
    }
679✔
51

×
52
    pub fn get_endpoint(&self, source_name: &str) -> Result<Endpoint, ExecutionError> {
23✔
53
        get_endpoint_from_mappings(&self.mappings, source_name)
23✔
54
    }
23✔
55

×
56
    pub fn new() -> Self {
676✔
57
        Self::default()
676✔
58
    }
676✔
59
}
×
60

61
pub fn get_endpoint_from_mappings(
1,019✔
62
    mappings: &[AppSourceMappings],
1,019✔
63
    source_name: &str,
1,019✔
64
) -> Result<Endpoint, ExecutionError> {
1,019✔
65
    let mut found: Vec<Endpoint> = mappings
1,019✔
66
        .iter()
1,019✔
67
        .filter_map(|mapping| {
1,026✔
68
            mapping.mappings.get(source_name).map(|output_port| {
1,026✔
69
                Endpoint::new(
1,017✔
70
                    NodeHandle::new(None, mapping.connection.clone()),
1,017✔
71
                    *output_port,
1,017✔
72
                )
1,017✔
73
            })
1,026✔
74
        })
1,026✔
75
        .collect();
1,019✔
76

1,019✔
77
    match found.len() {
1,019✔
78
        0 => Err(InvalidSourceIdentifier(source_name.to_string())),
2✔
79
        1 => Ok(found.remove(0)),
1,017✔
80
        _ => Err(AmbiguousSourceIdentifier(source_name.to_string())),
×
81
    }
×
82
}
1,019✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc