ferroui_dynamic_data/binding/
binding_options.rs1#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5pub struct BindingOptions {
6 pub reset_threshold: usize,
9 pub use_replace_for_updates: bool,
12 pub reset_on_first_time_load: bool,
14}
15
16impl BindingOptions {
17 pub const DEFAULT_RESET_THRESHOLD: usize = 25;
19 pub const DEFAULT_USE_REPLACE_FOR_UPDATES: bool = true;
21 pub const DEFAULT_RESET_ON_FIRST_TIME_LOAD: bool = true;
23
24 pub const fn new(reset_threshold: usize) -> Self {
27 Self { reset_threshold, use_replace_for_updates: Self::DEFAULT_USE_REPLACE_FOR_UPDATES, reset_on_first_time_load: Self::DEFAULT_RESET_ON_FIRST_TIME_LOAD }
28 }
29
30 pub const fn with_all(reset_threshold: usize, use_replace_for_updates: bool, reset_on_first_time_load: bool) -> Self {
32 Self { reset_threshold, use_replace_for_updates, reset_on_first_time_load }
33 }
34
35 pub const fn never_fire_reset() -> Self {
38 Self::never_fire_reset_with(Self::DEFAULT_RESET_ON_FIRST_TIME_LOAD)
39 }
40
41 pub const fn never_fire_reset_with(use_replace_for_updates: bool) -> Self {
44 Self { reset_threshold: usize::MAX, use_replace_for_updates, reset_on_first_time_load: false }
45 }
46
47 pub const fn with_reset_threshold(self, reset_threshold: usize) -> Self {
49 Self { reset_threshold, ..self }
50 }
51
52 pub const fn with_use_replace_for_updates(self, use_replace_for_updates: bool) -> Self {
54 Self { use_replace_for_updates, ..self }
55 }
56
57 pub const fn with_reset_on_first_time_load(self, reset_on_first_time_load: bool) -> Self {
59 Self { reset_on_first_time_load, ..self }
60 }
61}
62
63impl Default for BindingOptions {
64 fn default() -> Self {
66 Self::new(Self::DEFAULT_RESET_THRESHOLD)
67 }
68}