MCPcopy Index your code
hub / github.com/InfinitiBit/graphbit / row_to_memory

Function row_to_memory

core/src/memory/store.rs:261–300  ·  view source on GitHub ↗
(row: &rusqlite::Row<'_>)

Source from the content-addressed store, hash-verified

259// ---------------------------------------------------------------------------
260
261fn row_to_memory(row: &rusqlite::Row<'_>) -> GraphBitResult<Memory> {
262 let id_str: String = row.get(0)?;
263 let content: String = row.get(1)?;
264 let user_id: Option<String> = row.get(2)?;
265 let agent_id: Option<String> = row.get(3)?;
266 let run_id: Option<String> = row.get(4)?;
267 let hash: String = row.get(5)?;
268 let metadata_json: String = row.get(6)?;
269 let created_at_str: String = row.get(7)?;
270 let updated_at_str: String = row.get(8)?;
271
272 let id = MemoryId(Uuid::parse_str(&id_str).map_err(|e| {
273 GraphBitError::memory(format!("Invalid UUID in database: {e}"))
274 })?);
275
276 let metadata: HashMap<String, serde_json::Value> =
277 serde_json::from_str(&metadata_json).unwrap_or_default();
278
279 let created_at = DateTime::parse_from_rfc3339(&created_at_str)
280 .map(|dt| dt.with_timezone(&Utc))
281 .unwrap_or_else(|_| Utc::now());
282
283 let updated_at = DateTime::parse_from_rfc3339(&updated_at_str)
284 .map(|dt| dt.with_timezone(&Utc))
285 .unwrap_or_else(|_| Utc::now());
286
287 Ok(Memory {
288 id,
289 content,
290 scope: MemoryScope {
291 user_id,
292 agent_id,
293 run_id,
294 },
295 metadata,
296 created_at,
297 updated_at,
298 hash,
299 })
300}
301
302fn row_to_history(row: &rusqlite::Row<'_>) -> GraphBitResult<MemoryHistory> {
303 let memory_id_str: String = row.get(0)?;

Callers 2

get_memoryMethod · 0.85
get_all_memoriesMethod · 0.85

Calls 2

MemoryIdClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected