pub struct ProcessEnv { /* private fields */ }
Expand description
A struct that can be easily shared, stored in Lua app data, and that also guarantees the pairs are valid OS strings that can be used for process environment variables.
Usable directly from Lua, implementing both FromLua
and LuaUserData
.
Also provides convenience methods for working with the variables
as either OsString
or Vec<u8>
, where using the latter implicitly
converts to an OsString
and fails if the conversion is not possible.
Implementations§
Source§impl ProcessEnv
impl ProcessEnv
pub fn empty() -> Self
pub fn current() -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get_all(&self) -> Vec<(OsString, OsString)>
pub fn get_value(&self, key: impl AsRef<OsStr>) -> Option<OsString>
pub fn set_value(&self, key: impl Into<OsString>, val: impl Into<OsString>)
pub fn remove_value(&self, key: impl AsRef<OsStr>)
pub fn get_all_bytes(&self) -> Vec<(Vec<u8>, Vec<u8>)>
pub fn get_value_bytes(&self, key: impl AsRef<[u8]>) -> Option<Vec<u8>>
pub fn set_value_bytes(&self, key: impl AsRef<[u8]>, val: impl Into<Vec<u8>>)
pub fn remove_value_bytes(&self, key: impl AsRef<[u8]>)
Trait Implementations§
Source§impl Clone for ProcessEnv
impl Clone for ProcessEnv
Source§fn clone(&self) -> ProcessEnv
fn clone(&self) -> ProcessEnv
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ProcessEnv
impl Debug for ProcessEnv
Source§impl<K: Into<OsString>, V: Into<OsString>> Extend<(K, V)> for ProcessEnv
impl<K: Into<OsString>, V: Into<OsString>> Extend<(K, V)> for ProcessEnv
Source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<K: Into<OsString>, V: Into<OsString>> FromIterator<(K, V)> for ProcessEnv
impl<K: Into<OsString>, V: Into<OsString>> FromIterator<(K, V)> for ProcessEnv
Source§impl FromLua for ProcessEnv
impl FromLua for ProcessEnv
Source§impl IntoIterator for ProcessEnv
impl IntoIterator for ProcessEnv
Source§impl UserData for ProcessEnv
impl UserData for ProcessEnv
Source§fn add_methods<M: LuaUserDataMethods<Self>>(methods: &mut M)
fn add_methods<M: LuaUserDataMethods<Self>>(methods: &mut M)
Adds custom methods and operators specific to this userdata.
Source§fn add_fields<F>(fields: &mut F)where
F: UserDataFields<Self>,
fn add_fields<F>(fields: &mut F)where
F: UserDataFields<Self>,
Adds custom fields specific to this userdata.
Source§fn register(registry: &mut UserDataRegistry<Self>)
fn register(registry: &mut UserDataRegistry<Self>)
Registers this type for use in Lua. Read more
Auto Trait Implementations§
impl Freeze for ProcessEnv
impl RefUnwindSafe for ProcessEnv
impl Send for ProcessEnv
impl Sync for ProcessEnv
impl Unpin for ProcessEnv
impl UnwindSafe for ProcessEnv
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§impl<T> FromLuaMulti for Twhere
T: FromLua,
impl<T> FromLuaMulti for Twhere
T: FromLua,
Source§fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
Performs the conversion. Read more
fn from_lua_args( args: MultiValue, i: usize, to: Option<&str>, lua: &Lua, ) -> Result<T, Error>
unsafe fn from_stack_multi(nvals: i32, lua: &RawLua) -> Result<T, Error>
unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &RawLua, ) -> Result<T, Error>
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 moreSource§impl<T> IntoLuaMulti for Twhere
T: IntoLua,
impl<T> IntoLuaMulti for Twhere
T: IntoLua,
Source§fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue, Error>
fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue, Error>
Performs the conversion.