monsta_server/
collection.rs1use std::sync::Arc;
2
3use monsta_proto::*;
4use tokio::sync::Mutex;
5
6#[derive(Clone)]
7pub struct Collection {
8 inner: Arc<Mutex<Inner>>,
9}
10
11struct Inner {
12 desc: CollectionDesc,
13}
14
15impl Collection {
16 pub fn new(database_id: u64, collection_id: u64, spec: CollectionSpec) -> Self {
17 let desc = CollectionDesc {
18 id: collection_id,
19 name: spec.name,
20 database_id,
21 };
22 let inner = Inner { desc };
23 Self {
24 inner: Arc::new(Mutex::new(inner)),
25 }
26 }
27
28 pub async fn desc(&self) -> CollectionDesc {
29 let inner = self.inner.lock().await;
30 inner.desc.clone()
31 }
32}