Skip to main content

reddb_server/storage/unified/devx/
conversions.rs

1//! Value Conversions for Ergonomics
2//!
3//! From implementations for Value and MetadataValue for fluent API.
4
5use super::super::{MetadataValue, RefTarget};
6use super::refs::{NodeRef, TableRef, VectorRef};
7
8// ============================================================================
9// Value Conversions
10// ============================================================================
11//
12// The `From<primitive> for Value` impls were re-homed to the keystone crate
13// `reddb-io-types` alongside `Value` itself (ADR 0052, #1061): with `Value`
14// no longer local here, the orphan rule requires those impls to live in
15// `Value`'s home crate. See `reddb_types::conversions`.
16
17// ============================================================================
18// MetadataValue Conversions
19// ============================================================================
20
21impl From<TableRef> for MetadataValue {
22    fn from(r: TableRef) -> Self {
23        MetadataValue::Reference(RefTarget::table(r.table, r.row_id))
24    }
25}
26
27impl From<NodeRef> for MetadataValue {
28    fn from(r: NodeRef) -> Self {
29        MetadataValue::Reference(RefTarget::node(r.collection, r.node_id))
30    }
31}
32
33impl From<VectorRef> for MetadataValue {
34    fn from(r: VectorRef) -> Self {
35        MetadataValue::Reference(RefTarget::vector(r.collection, r.vector_id))
36    }
37}