use crate::Network;
use crate::Roots;
use crate::store::Store;
pub struct NetworkBuilder<S>
where S: Store
{
store: S,
roots: Roots,
certification_network: bool,
maximum_depth: Option<usize>,
}
impl<S> NetworkBuilder<S>
where S: Store
{
pub fn rooted<R>(store: S, roots: R) -> Self
where R: Into<Roots>,
{
tracer!(TRACE, "NetworkBuilder::rooted");
Self {
store,
roots: roots.into(),
certification_network: false,
maximum_depth: None,
}
}
pub fn rootless(store: S) -> Self
{
tracer!(TRACE, "NetworkBuilder::rooted");
Self {
store,
roots: Roots::empty(),
certification_network: false,
maximum_depth: None,
}
}
pub fn certification_network(mut self) -> Self
{
tracer!(TRACE, "NetworkBuilder::certification_network");
self.certification_network = true;
self
}
pub fn authentication_network(mut self) -> Self {
self.certification_network = false;
self
}
pub fn maximum_depth(mut self, limit: usize) -> Self {
self.maximum_depth = Some(limit);
self
}
pub fn build(self) -> Network<S> {
Network {
store: self.store,
roots: self.roots,
certification_network: self.certification_network,
maximum_depth: self.maximum_depth,
}
}
}