Struct aws_types::os_shim_internal::Env
source · pub struct Env(/* private fields */);
Expand description
Environment variable abstraction
Environment variables are global to a process, and, as such, are difficult to test with a multi-
threaded test runner like Rust’s. This enables loading environment variables either from the
actual process environment (std::env::var
) or from a hash map.
Process environments are cheap to clone:
- Faked process environments are wrapped in an internal Arc
- Real process environments are pointer-sized
Implementations§
source§impl Env
impl Env
sourcepub fn get(&self, k: &str) -> Result<String, VarError>
pub fn get(&self, k: &str) -> Result<String, VarError>
Retrieve a value for the given k
and return VarError
is that key is not present.
sourcepub fn from_slice<'a>(vars: &[(&'a str, &'a str)]) -> Self
pub fn from_slice<'a>(vars: &[(&'a str, &'a str)]) -> Self
Create a fake process environment from a slice of tuples.
§Examples
use aws_types::os_shim_internal::Env;
let mock_env = Env::from_slice(&[
("HOME", "/home/myname"),
("AWS_REGION", "us-west-2")
]);
assert_eq!(mock_env.get("HOME").unwrap(), "/home/myname");
sourcepub fn real() -> Self
pub fn real() -> Self
Create a process environment that uses the real process environment
Calls will be delegated to std::env::var
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Env
impl RefUnwindSafe for Env
impl Send for Env
impl Sync for Env
impl Unpin for Env
impl UnwindSafe for Env
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.