Struct Parser

Source
pub struct Parser {
    pub prefix: Option<String>,
    pub separator: String,
    pub include: Vec<Regex>,
    pub exclude: Vec<Regex>,
    pub json: Value,
}
Expand description

Parse environment variables into json

Fields§

§prefix: Option<String>

The prefix to use when parsing environment variables

§separator: String

The separator to use when parsing environment variables

§include: Vec<Regex>
Available on crate feature filter only.

List of regex patterns to include. One of the patterns must match for the variable to be included

§exclude: Vec<Regex>
Available on crate feature filter only.

List of regex patterns to exclude. All of the patterns must not match for the variable to be included

§json: Value

The json object to merge the parsed environment variables into

Implementations§

Source§

impl Parser

Source

pub fn with_prefix(self, prefix: impl Into<String>) -> Self

Return a new parser with the given prefix

Source

pub fn with_separator(self, separator: impl Into<String>) -> Self

Return a new parser with the given separator

Source

pub fn with_include(self, include: &[&str]) -> Self

Available on crate feature filter only.

Return a new parser with the given include patterns Requires the filter feature

Source

pub fn with_exclude(self, exclude: &[&str]) -> Self

Available on crate feature filter only.

Return a new parser with the given exclude patterns

Source

pub fn with_json(self, json: Value) -> Self

Return a new parser with the given json object

Source

pub fn parse_from_env(&self) -> Result<Value, Error>

Parse environment variables into json

Source

pub fn parse_iter( &self, vars: impl Iterator<Item = (String, String)>, ) -> Result<Value, Error>

Parse iterator of String tuples into json

Source

pub fn json_get_mut<'a>( json: &'a mut Value, indices: &'a [JsonIndex], ) -> Option<&'a mut Value>

Get mutable reference to json value at indices

Trait Implementations§

Source§

impl Debug for Parser

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Parser

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Parser

§

impl RefUnwindSafe for Parser

§

impl Send for Parser

§

impl Sync for Parser

§

impl Unpin for Parser

§

impl UnwindSafe for Parser

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.