nom_config_in/entry/
env_variable.rs1use nom::{bytes::complete::tag, combinator::map, sequence::tuple, IResult};
2use serde::Serialize;
3
4use crate::{symbol::parse_constant_symbol, util::ws, ConfigInInput};
5
6#[derive(Debug, Clone, Serialize, PartialEq)]
7pub struct EnvVariable {
8 pub name: String,
9 pub value: String,
10}
11
12pub fn parse_env_variable(input: ConfigInInput) -> IResult<ConfigInInput, EnvVariable> {
13 map(
14 tuple((
15 ws(parse_constant_symbol),
16 ws(tag("=")),
17 ws(parse_constant_symbol),
18 )),
19 |(name, _, value)| EnvVariable {
20 name: name.to_string(),
21 value: value.to_string(),
22 },
23 )(input)
24}