Struct tor_config::list_builder::VecBuilder
source · [−]pub struct VecBuilder<T> where
T: Clone, { /* private fields */ }
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.
Implementations
sourceimpl<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.
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
sourceimpl<T: Clone> Clone for VecBuilder<T> where
T: Clone,
impl<T: Clone> Clone for VecBuilder<T> where
T: Clone,
sourcefn clone(&self) -> VecBuilder<T>
fn clone(&self) -> VecBuilder<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<T: Debug> Debug for VecBuilder<T> where
T: Clone,
impl<T: Debug> Debug for VecBuilder<T> where
T: Clone,
sourceimpl<T> Default for VecBuilder<T> where
T: Clone,
impl<T> Default for VecBuilder<T> where
T: Clone,
sourceimpl<'de, T> Deserialize<'de> for VecBuilder<T> where
T: Clone,
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for VecBuilder<T> where
T: Clone,
T: Deserialize<'de>,
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more