pub struct PrefixWhitelistPolicy { /* private fields */ }Expand description
Allows only environment variables whose names start with one of the given prefixes.
Implementations§
Source§impl PrefixWhitelistPolicy
impl PrefixWhitelistPolicy
Sourcepub fn new(prefixes: Vec<String>) -> Self
pub fn new(prefixes: Vec<String>) -> Self
Create a prefix-based whitelist policy.
Examples found in repository?
examples/prefix_whitelist.rs (line 10)
6fn main() {
7 // SAFETY: single-threaded example, no concurrent env access.
8 unsafe { std::env::set_var("APP_HOST", "example.internal") };
9
10 let policy = PrefixWhitelistPolicy::new(vec!["APP_".to_string()]);
11 let resolver = EnvValueResolver;
12 let substituter = Substituter::new(&policy, &resolver, "example.toml".to_string());
13
14 match substituter.substitute("host = {{APP_HOST}}") {
15 Ok(value) => println!("{value}"),
16 Err(e) => eprintln!("substitution failed: {e}"),
17 }
18}Trait Implementations§
Source§impl Debug for PrefixWhitelistPolicy
impl Debug for PrefixWhitelistPolicy
Auto Trait Implementations§
impl Forget for PrefixWhitelistPolicy
impl Freeze for PrefixWhitelistPolicy
impl RefUnwindSafe for PrefixWhitelistPolicy
impl Send for PrefixWhitelistPolicy
impl Sync for PrefixWhitelistPolicy
impl Unpin for PrefixWhitelistPolicy
impl UnsafeUnpin for PrefixWhitelistPolicy
impl UnwindSafe for PrefixWhitelistPolicy
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