use serde::{Deserialize, Serialize}; use crate::db::{SledModel, Storable}; use std::collections::HashMap; /// Circle represents a collection of members (users or other circles) #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Circle { pub id: u32, // unique id pub name: String, // name of the circle pub description: String, // optional description } impl Circle { /// Create a new circle pub fn new(id: u32, name: String, description: String) -> Self { Self { id, name, description, } } /// Returns a map of index keys for this circle pub fn index_keys(&self) -> HashMap { let mut keys = HashMap::new(); keys.insert("name".to_string(), self.name.clone()); keys } } // Implement Storable trait (provides default dump/load) impl Storable for Circle {} // Implement SledModel trait impl SledModel for Circle { fn get_id(&self) -> String { self.id.to_string() } fn db_prefix() -> &'static str { "circle" } }