1use super::{bootstrap, CoreError, Module, RuestApplication};
2
3pub struct RuestFactory;
5
6impl RuestFactory {
7 pub fn create<M: Module>(root: M) -> Result<ApplicationBuilder, CoreError> {
9 let app = bootstrap(root)?;
10 Ok(ApplicationBuilder { app })
11 }
12}
13
14pub struct ApplicationBuilder {
16 app: RuestApplication,
17}
18
19impl ApplicationBuilder {
20 pub fn port(mut self, port: u16) -> Self {
21 self.app.set_port(port);
22 self
23 }
24
25 pub fn host(mut self, host: impl Into<String>) -> Self {
26 self.app.set_host(host);
27 self
28 }
29
30 pub fn build(self) -> RuestApplication {
31 self.app
32 }
33}