reifydb_core/value/column/push/
uuid.rs

1// Copyright (c) reifydb.com 2025
2// This file is licensed under the AGPL-3.0-or-later, see license.md file
3
4use reifydb_type::{Uuid4, Uuid7};
5
6use crate::value::column::{data::ColumnData, push::Push};
7
8impl Push<Uuid4> for ColumnData {
9	fn push(&mut self, value: Uuid4) {
10		match self {
11			ColumnData::Uuid4(container) => container.push(value),
12			ColumnData::Undefined(container) => {
13				let mut new_container = ColumnData::uuid4(vec![Uuid4::default(); container.len()]);
14				if let ColumnData::Uuid4(new_container) = &mut new_container {
15					new_container.push(value);
16				}
17				*self = new_container;
18			}
19			other => {
20				panic!(
21					"called `push::<Uuid4>()` on incompatible EngineColumnData::{:?}",
22					other.get_type()
23				);
24			}
25		}
26	}
27}
28
29impl Push<Uuid7> for ColumnData {
30	fn push(&mut self, value: Uuid7) {
31		match self {
32			ColumnData::Uuid7(container) => container.push(value),
33			ColumnData::Undefined(container) => {
34				let mut new_container = ColumnData::uuid7(vec![Uuid7::default(); container.len()]);
35				if let ColumnData::Uuid7(new_container) = &mut new_container {
36					new_container.push(value);
37				}
38				*self = new_container;
39			}
40			other => {
41				panic!(
42					"called `push::<Uuid7>()` on incompatible EngineColumnData::{:?}",
43					other.get_type()
44				);
45			}
46		}
47	}
48}