Skip to main content

datex_core/values/value_container/
update_handler.rs

1use core::cell::RefCell;
2
3use crate::{
4    runtime::cache::shared_references_cache::SharedReferencesCache,
5    value_updates::{
6        update_data::Update,
7        update_handler::{UpdateHandler, UpdateResult},
8    },
9    values::value_container::ValueContainer,
10};
11
12impl UpdateHandler for ValueContainer {
13    fn try_handle_update(
14        &mut self,
15        update: Update,
16        cache: &RefCell<SharedReferencesCache>,
17    ) -> UpdateResult {
18        match self {
19            ValueContainer::Local(local) => {
20                let (source_id, operation, path) = update.into_parts();
21
22                local.try_update_collapsed_local_inner(
23                    operation,
24                    path,
25                    Some(source_id),
26                    cache,
27                )
28            }
29            ValueContainer::Shared(shared) => {
30                shared.try_handle_update(update, cache)
31            }
32        }
33    }
34}