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§
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.
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>where
T: Clone + Clone,
impl<T> Clone for VecBuilder<T>where T: Clone + Clone,
source§fn clone(&self) -> VecBuilder<T>
fn clone(&self) -> VecBuilder<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§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>,
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§
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