Skip to main content

chroma_types/
tenant.rs

1use crate::chroma_proto::TenantLastCompactionTime;
2
3#[derive(Debug, Clone)]
4pub struct Tenant {
5    pub id: String,
6    pub last_compaction_time: i64,
7    pub resource_name: Option<String>,
8}
9
10impl TryFrom<TenantLastCompactionTime> for Tenant {
11    type Error = ();
12
13    fn try_from(proto_tenant: TenantLastCompactionTime) -> Result<Self, Self::Error> {
14        Ok(Tenant {
15            id: proto_tenant.tenant_id,
16            last_compaction_time: proto_tenant.last_compaction_time,
17            resource_name: None,
18        })
19    }
20}
21
22impl From<Tenant> for crate::chroma_proto::Tenant {
23    fn from(tenant: Tenant) -> Self {
24        crate::chroma_proto::Tenant {
25            name: tenant.id,
26            resource_name: tenant.resource_name,
27        }
28    }
29}