pub struct BoolVar { /* private fields */ }Expand description
Bind one boolean value.
Implementations§
Source§impl BoolVar
impl BoolVar
Sourcepub fn new(name: impl Into<VariableName>) -> Self
pub fn new(name: impl Into<VariableName>) -> Self
Build a boolean variable.
Examples found in repository?
examples/service_settings.rs (line 23)
14 fn bind<E: Environment>(binder: &Binder<E>) -> Result<Self, envbind::BindError> {
15 Ok(Self {
16 host: binder.bind(&StringVar::new("SERVICE_HOST").default("127.0.0.1"))?,
17 port: binder.bind(
18 &U16Var::new("SERVICE_PORT")
19 .default(8080)
20 .validate(validators::u16_in_range(1, 65_535)),
21 )?,
22 service_name: binder.bind(&StringVar::new("SERVICE_NAME").default("api"))?,
23 tracing_enabled: binder.bind(&BoolVar::new("SERVICE_TRACING").default(false))?,
24 })
25 }Sourcepub fn default(self, value: bool) -> Self
pub fn default(self, value: bool) -> Self
Provide a fallback value when the variable is missing.
Examples found in repository?
examples/service_settings.rs (line 23)
14 fn bind<E: Environment>(binder: &Binder<E>) -> Result<Self, envbind::BindError> {
15 Ok(Self {
16 host: binder.bind(&StringVar::new("SERVICE_HOST").default("127.0.0.1"))?,
17 port: binder.bind(
18 &U16Var::new("SERVICE_PORT")
19 .default(8080)
20 .validate(validators::u16_in_range(1, 65_535)),
21 )?,
22 service_name: binder.bind(&StringVar::new("SERVICE_NAME").default("api"))?,
23 tracing_enabled: binder.bind(&BoolVar::new("SERVICE_TRACING").default(false))?,
24 })
25 }Sourcepub fn allow_empty(self) -> Self
pub fn allow_empty(self) -> Self
Parse empty strings instead of treating them as missing.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BoolVar
impl !RefUnwindSafe for BoolVar
impl Send for BoolVar
impl Sync for BoolVar
impl Unpin for BoolVar
impl UnsafeUnpin for BoolVar
impl !UnwindSafe for BoolVar
Blanket Implementations§
Source§impl<B> BindingExt for B
impl<B> BindingExt for B
Source§fn optional(self) -> OptionalVar<Self>
fn optional(self) -> OptionalVar<Self>
Treat missing or explicitly empty values as
None. Read moreSource§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