timber_rust/factory/
write.rs

1use crate::service::Vector;
2
3pub struct WriteFactory;
4
5pub struct VectorFactory {
6    capacity: usize,
7}
8
9impl WriteFactory {
10    pub fn io() {}
11
12    pub fn fmt() {}
13
14    pub fn vector() -> VectorFactory {
15        VectorFactory::default()
16    }
17
18    pub fn vector_with_capacity(capacity: usize) -> VectorFactory {
19        VectorFactory { capacity }
20    }
21}
22
23impl VectorFactory {
24    pub fn new(capacity: usize) -> Self {
25        Self { capacity }
26    }
27
28    pub fn get_capacity(&self) -> usize {
29        self.capacity
30    }
31
32    pub fn capacity(self, capacity: usize) -> Self {
33        Self { capacity, ..self }
34    }
35
36    pub fn build_service(self) -> Box<Vector> {
37        Vector::new(self.capacity)
38    }
39}
40
41impl Default for VectorFactory {
42    fn default() -> Self {
43        Self { capacity: 1024 }
44    }
45}