Struct tor_config::list_builder::VecBuilder
source · pub struct VecBuilder<T>where
T: Clone,{
values: Option<Vec<T>>,
}
Expand description
List of T
, a straightforward type, being built as part of the configuration
The default is the empty list.
§Example
use derive_builder::Builder;
use serde::{Deserialize, Serialize};
use tor_config::ConfigBuildError;
use tor_config::{define_list_builder_accessors, list_builder::VecBuilder};
use std::net::SocketAddr;
#[derive(Debug, Clone, Builder)]
#[builder(build_fn(error = "ConfigBuildError"))]
#[builder(derive(Debug, Serialize, Deserialize))]
pub struct FallbackDir {
#[builder(sub_builder(fn_name = "build"), setter(custom))]
orports: Vec<SocketAddr>,
}
define_list_builder_accessors! {
struct FallbackDirBuilder {
pub orports: [SocketAddr],
}
}
let mut bld = FallbackDirBuilder::default();
bld.orports().push("[2001:db8:0::42]:12".parse().unwrap());
assert_eq!( bld.build().unwrap().orports[0].to_string(),
"[2001:db8::42]:12" );
Wrapper struct to help derive_builder find the right types and methods
This struct is not part of the configuration API. Refer to the containing structures for information on how to build the config.
Fields§
§values: Option<Vec<T>>
The list, as overridden
Implementations§
source§impl<T> VecBuilder<T>where
T: Clone,
impl<T> VecBuilder<T>where
T: Clone,
sourcepub fn build(&self) -> Result<Vec<T>, ConfigBuildError>
pub fn build(&self) -> Result<Vec<T>, ConfigBuildError>
Resolve this list to a list of built items.
If the value is still the Default
,
a built-in default list will be built and returned;
otherwise each applicable item will be built,
and the results collected into a single built list.
sourcefn default_list() -> Vec<T>
fn default_list() -> Vec<T>
The default list
sourcepub fn access(&mut self) -> &mut Vec<T>
pub fn access(&mut self) -> &mut Vec<T>
Resolve the list to the default if necessary and then return &mut Vec
sourcepub fn access_opt(&self) -> &Option<Vec<T>>
pub fn access_opt(&self) -> &Option<Vec<T>>
Resolve the list to the default if necessary and then return &mut Vec
sourcepub fn access_opt_mut(&mut self) -> &mut Option<Vec<T>>
pub fn access_opt_mut(&mut self) -> &mut Option<Vec<T>>
Resolve the list to the default if necessary and then return &mut Vec
Trait Implementations§
source§impl<T> Clone for VecBuilder<T>
impl<T> Clone for VecBuilder<T>
source§fn clone(&self) -> VecBuilder<T>
fn clone(&self) -> VecBuilder<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T> Debug for VecBuilder<T>
impl<T> Debug for VecBuilder<T>
source§impl<T> Default for VecBuilder<T>where
T: Clone,
impl<T> Default for VecBuilder<T>where
T: Clone,
source§impl<'de, T> Deserialize<'de> for VecBuilder<T>where
T: Clone + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for VecBuilder<T>where
T: Clone + Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl<T> Freeze for VecBuilder<T>
impl<T> RefUnwindSafe for VecBuilder<T>where
T: RefUnwindSafe,
impl<T> Send for VecBuilder<T>where
T: Send,
impl<T> Sync for VecBuilder<T>where
T: Sync,
impl<T> Unpin for VecBuilder<T>where
T: Unpin,
impl<T> UnwindSafe for VecBuilder<T>where
T: UnwindSafe,
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
§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>
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>
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 more