Skip to content

Commit f0bd103

Browse files
committed
Create SourceMap type alias for HashMap<String, Box<dyn Source>>
1 parent 1f3ade6 commit f0bd103

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

src/cli/update.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! The update subcommand used to get the latest allowed signers and write them to the output file.
2-
use crate::{AllowedSignersEntry, Config, Source, SshPublicKey};
3-
use std::collections::{HashMap, HashSet};
2+
use crate::{AllowedSignersEntry, Config, SourceMap, SshPublicKey};
3+
use std::collections::HashSet;
44

55
pub(super) fn update(config: Config) {
66
let sources = config.get_sources();
@@ -16,6 +16,6 @@ pub(super) fn update(config: Config) {
1616
}
1717
}
1818

19-
fn get_public_keys(user: (), sources: &HashMap<String, Box<dyn Source>>) -> Vec<SshPublicKey> {
19+
fn get_public_keys(user: (), sources: &SourceMap) -> Vec<SshPublicKey> {
2020
todo!("Retrieve public keys for a user from all sources.");
2121
}

src/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{Github, Gitlab, Source};
1+
use crate::{Github, Gitlab, Source, SourceMap};
22
use figment::{
33
providers::{Format, Serialized, Toml},
44
Figment,
@@ -46,7 +46,7 @@ impl Default for Config {
4646
impl Config {
4747
/// Get the configured sources.
4848
#[must_use]
49-
pub fn get_sources(&self) -> HashMap<String, Box<dyn Source>> {
49+
pub fn get_sources(&self) -> SourceMap {
5050
self.sources
5151
.iter()
5252
.map(|source_config| {

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
pub use config::Config;
66
pub use core::*;
77
pub use signer::{AllowedSignersEntry, AllowedSignersFile};
8-
pub use source::{Github, Gitlab, Source};
8+
pub use source::{Github, Gitlab, Source, SourceMap};
99

1010
pub mod cli;
1111
mod config;

src/source/main.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::SshPublicKey;
22
use async_trait::async_trait;
3+
use std::collections::HashMap;
34

45
/// A source implements a way to get public keys from a Git provider.
56
#[async_trait]
@@ -11,3 +12,6 @@ pub trait Source {
1112
client: &reqwest::Client,
1213
) -> Result<Vec<SshPublicKey>, reqwest::Error>;
1314
}
15+
16+
/// A `HashMap` containing named sources.
17+
pub type SourceMap = HashMap<String, Box<dyn Source>>;

src/source/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pub use github::Github;
22
pub use gitlab::Gitlab;
3-
pub use main::Source;
3+
pub use main::{Source, SourceMap};
44

55
mod github;
66
mod gitlab;

0 commit comments

Comments
 (0)