monsta_client/
collection.rs1use monsta_proto::*;
2
3use crate::{client::Client, Error, Result};
4
5pub struct Collection {
6 client: Client,
7 database_id: u64,
8 collection_id: u64,
9}
10
11impl Collection {
12 pub fn new(client: Client, database_id: u64, collection_id: u64) -> Self {
13 Self {
14 client,
15 database_id,
16 collection_id,
17 }
18 }
19
20 pub async fn desc(&self) -> Result<CollectionDesc> {
21 let req = CollectionRequest {
22 database_id: self.database_id,
23 describe_collection: Some(DescribeCollectionRequest {
24 id: self.collection_id,
25 ..Default::default()
26 }),
27 ..Default::default()
28 };
29 let res = self.client.collection_call(req).await?;
30 let desc = res
31 .describe_collection
32 .and_then(|x| x.desc)
33 .ok_or_else(|| Error::InvalidResponse)?;
34 Ok(desc)
35 }
36}