Struct EnvUtils

Source
pub struct EnvUtils;
Expand description

Utility functions related to environment variables.

Implementations§

Source§

impl EnvUtils

Source

pub fn get_property<K: AsRef<OsStr>>(key: K) -> Option<String>

Gets the value of the specified environment variable.

§Arguments
  • key - The name of the environment variable to retrieve.
§Returns

An Option containing the value of the environment variable, or None if the variable is not set.

Source

pub fn get_property_or_default<K: AsRef<OsStr>>( key: K, default: impl Into<String>, ) -> String

Retrieves the value of the specified environment variable or returns a default value if the variable is not set.

§Arguments
  • key - The name of the environment variable to retrieve.
  • default - The default value to return if the environment variable is not set.
§Returns

A String containing the value of the environment variable, or the default value.

Source

pub fn get_property_as_i32<K: AsRef<OsStr>>(key: K, default: i32) -> i32

Retrieves the value of the specified environment variable as an i32, or returns a default value if the variable is not set or cannot be parsed.

§Arguments
  • key - The name of the environment variable to retrieve.
  • default - The default value to return if the environment variable is not set or cannot be parsed.
§Returns

An i32 containing the value of the environment variable, or the default value.

Source

pub fn get_property_as_bool<K: AsRef<OsStr>>(key: K, default: bool) -> bool

Retrieves the value of the specified environment variable as a bool, or returns a default value if the variable is not set or cannot be parsed.

§Arguments
  • key - The name of the environment variable to retrieve.
  • default - The default value to return if the environment variable is not set or cannot be parsed.
§Returns

A bool containing the value of the environment variable, or the default value.

§Notes

The function considers the following values as true: "true", "1". The function considers the following values as false: "false", "0".

Source

pub fn put_property<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V)

Sets the value of the specified environment variable.

§Arguments
  • key - The name of the environment variable to set.
  • value - The value to set the environment variable to.
§Safety

This function uses unsafe because it modifies the environment variables, which can have side effects on the entire process.

Source

pub fn get_rocketmq_home() -> String

Gets the value of the ROCKETMQ_HOME environment variable.

If ROCKETMQ_HOME is not set, it defaults to the current directory and sets ROCKETMQ_HOME accordingly.

§Returns

The value of the ROCKETMQ_HOME environment variable as a String.

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T