1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//! Metadata storage system for EdgeVec.
//!
//! This module provides a type-safe metadata storage system for attaching
//! key-value pairs to vectors. Metadata enables filtering, sorting, and
//! enriching vector search results with additional context.
//!
//! # Features
//!
//! - **5 Value Types**: String, Integer, Float, Boolean, StringArray
//! - **Type-Safe**: Strongly typed values with accessor methods
//! - **Validated**: Keys and values are validated against limits
//! - **Serializable**: JSON serialization with clear type tags
//!
//! # Quick Start
//!
//! ```rust
//! use edgevec::metadata::{MetadataValue, MetadataStore};
//! use edgevec::metadata::validation::validate_key_value;
//!
//! // Create values using constructors
//! let title = MetadataValue::String("Hello World".to_string());
//! let count = MetadataValue::Integer(42);
//! let score = MetadataValue::Float(0.95);
//! let active = MetadataValue::Boolean(true);
//! let tags = MetadataValue::StringArray(vec!["rust".into(), "wasm".into()]);
//!
//! // Create values using From trait
//! let title: MetadataValue = "Hello World".into();
//! let count: MetadataValue = 42i64.into();
//! let active: MetadataValue = true.into();
//!
//! // Validate before storing
//! assert!(validate_key_value("title", &title).is_ok());
//!
//! // Check types
//! assert!(title.is_string());
//! assert!(count.is_integer());
//!
//! // Extract values
//! assert_eq!(title.as_string(), Some("Hello World"));
//! assert_eq!(count.as_integer(), Some(42));
//! ```
//!
//! # Value Types
//!
//! | Type | Rust | JSON | Use Case |
//! |:-----|:-----|:-----|:---------|
//! | String | `String` | `string` | Titles, descriptions |
//! | Integer | `i64` | `number` | Counts, IDs, timestamps |
//! | Float | `f64` | `number` | Scores, weights |
//! | Boolean | `bool` | `boolean` | Flags, filters |
//! | StringArray | `Vec<String>` | `string[]` | Tags, categories |
//!
//! # Validation Limits
//!
//! | Limit | Value | Description |
//! |:------|:------|:------------|
//! | Max keys per vector | 64 | Prevents memory bloat |
//! | Max key length | 256 bytes | Reasonable for field names |
//! | Max string value | 64KB | Prevents abuse |
//! | Max array elements | 1,024 | Prevents excessive arrays |
//!
//! # JSON Serialization
//!
//! Values serialize with adjacently-tagged representation:
//!
//! ```json
//! {"type": "string", "value": "hello"}
//! {"type": "integer", "value": 42}
//! {"type": "float", "value": 2.5}
//! {"type": "boolean", "value": true}
//! {"type": "string_array", "value": ["a", "b"]}
//! ```
//!
//! # Module Structure
//!
//! - `types` - Core `MetadataValue` enum
//! - `error` - `MetadataError` enum
//! - `validation` - Validation constants and functions
//! - `store` - `MetadataStore` for CRUD operations (Day 2)
// Re-export public types at module level
pub use MetadataError;
pub use SerializationError;
pub use MetadataStore;
pub use MetadataValue;