mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-25 08:12:19 +01:00
43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
use std::collections::HashMap;
|
|
use shared::model::InputFetchMethod;
|
|
use crate::model::{ConfigInput, StagedInput};
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct InputSource {
|
|
pub url: String,
|
|
pub username: Option<String>,
|
|
pub password: Option<String>,
|
|
pub method: InputFetchMethod,
|
|
pub headers: HashMap<String, String>,
|
|
}
|
|
|
|
impl InputSource {
|
|
pub fn with_url(&self, url: String) -> Self {
|
|
Self {
|
|
url,
|
|
username: self.username.clone(),
|
|
password: self.password.clone(),
|
|
method: self.method,
|
|
headers: self.headers.clone(),
|
|
}
|
|
}
|
|
}
|
|
|
|
macro_rules! impl_input_source_from {
|
|
($input_type:ty) => {
|
|
impl From<&$input_type> for InputSource {
|
|
fn from(input: &$input_type) -> Self {
|
|
Self {
|
|
url: input.url.clone(),
|
|
username: input.username.clone(),
|
|
password: input.password.clone(),
|
|
method: input.method,
|
|
headers: input.headers.clone(),
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
impl_input_source_from!(ConfigInput);
|
|
impl_input_source_from!(StagedInput); |