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 (const: unstable) · 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>,
Source§impl<T> ExtendBuilder for VecBuilder<T>where
T: Clone,
impl<T> ExtendBuilder for VecBuilder<T>where
T: Clone,
Source§fn extend_from(&mut self, other: Self, strategy: ExtendStrategy)
fn extend_from(&mut self, other: Self, strategy: ExtendStrategy)
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> UnsafeUnpin for VecBuilder<T>
impl<T> UnwindSafe for VecBuilder<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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