mlmdquery/
context_types.rs1use crate::serialize::Type;
3
4#[derive(Debug, Clone, structopt::StructOpt, serde::Serialize, serde::Deserialize)]
6#[structopt(rename_all = "kebab-case")]
7pub struct ContextTypesOpt {
8 #[structopt(long, env = "MLMD_DB", hide_env_values = true)]
10 #[serde(skip)]
11 pub db: String,
12}
13
14impl ContextTypesOpt {
15 pub async fn count(&self, store: &mut mlmd::MetadataStore) -> anyhow::Result<usize> {
17 Ok(self.get(store).await?.len())
18 }
19
20 pub async fn get(&self, store: &mut mlmd::MetadataStore) -> anyhow::Result<Vec<Type>> {
22 let types = store.get_context_types().execute().await?;
23 Ok(types.into_iter().map(Type::from).collect())
24 }
25}