toql_core/backend/
context_builder.rs1use super::context::Context;
2use crate::{alias_format::AliasFormat, sql_arg::SqlArg};
3use std::collections::{HashMap, HashSet};
4
5pub struct ContextBuilder {
6 pub roles: HashSet<String>,
7 pub aux_params: HashMap<String, SqlArg>,
8 pub alias_format: AliasFormat,
9}
10
11impl ContextBuilder {
12 pub fn new() -> Self {
13 ContextBuilder {
14 roles: HashSet::new(),
15 aux_params: HashMap::new(),
16 alias_format: AliasFormat::Canonical,
17 }
18 }
19
20 pub fn with_roles(mut self, roles: HashSet<String>) -> Self {
21 self.roles = roles;
22 self
23 }
24 pub fn with_aux_params(mut self, aux_params: HashMap<String, SqlArg>) -> Self {
25 self.aux_params = aux_params;
26 self
27 }
28 pub fn with_alias_format(mut self, alias_format: AliasFormat) -> Self {
29 self.alias_format = alias_format;
30 self
31 }
32 pub fn build(self) -> Context {
33 Context {
34 roles: self.roles,
35 aux_params: self.aux_params,
36 alias_format: self.alias_format,
37 }
38 }
39}
40
41impl Default for ContextBuilder {
42 fn default() -> Self {
43 Self::new()
44 }
45}