use candid::CandidType;
use serde::Deserialize;
#[cfg_attr(
doc,
doc = "EntityCatalogCounts\n\nCompact count metadata for one SHOW ENTITIES row."
)]
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
pub struct EntityCatalogCounts {
columns: u32,
indexes: u32,
relations: u32,
schema_version: u32,
}
impl EntityCatalogCounts {
#[must_use]
pub const fn new(columns: u32, indexes: u32, relations: u32, schema_version: u32) -> Self {
Self {
columns,
indexes,
relations,
schema_version,
}
}
}
#[cfg_attr(
doc,
doc = "EntityCatalogDescription\n\nRuntime catalog entry for one registered entity."
)]
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
pub struct EntityCatalogDescription {
entity_name: String,
entity_path: String,
store_path: String,
storage: String,
columns: u32,
indexes: u32,
relations: u32,
schema_version: u32,
}
impl EntityCatalogDescription {
#[must_use]
pub const fn new(
entity_name: String,
entity_path: String,
store_path: String,
storage: String,
counts: EntityCatalogCounts,
) -> Self {
Self {
entity_name,
entity_path,
store_path,
storage,
columns: counts.columns,
indexes: counts.indexes,
relations: counts.relations,
schema_version: counts.schema_version,
}
}
#[must_use]
pub const fn entity_name(&self) -> &str {
self.entity_name.as_str()
}
#[must_use]
pub const fn entity_path(&self) -> &str {
self.entity_path.as_str()
}
#[must_use]
pub const fn store_path(&self) -> &str {
self.store_path.as_str()
}
#[must_use]
pub const fn storage(&self) -> &str {
self.storage.as_str()
}
#[must_use]
pub const fn columns(&self) -> u32 {
self.columns
}
#[must_use]
pub const fn indexes(&self) -> u32 {
self.indexes
}
#[must_use]
pub const fn relations(&self) -> u32 {
self.relations
}
#[must_use]
pub const fn schema_version(&self) -> u32 {
self.schema_version
}
}
#[cfg_attr(
doc,
doc = "StoreCatalogDescription\n\nRuntime catalog entry for one registered store."
)]
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
pub struct StoreCatalogDescription {
store_path: String,
storage: String,
}
impl StoreCatalogDescription {
#[must_use]
pub const fn new(store_path: String, storage: String) -> Self {
Self {
store_path,
storage,
}
}
#[must_use]
pub const fn store_path(&self) -> &str {
self.store_path.as_str()
}
#[must_use]
pub const fn storage(&self) -> &str {
self.storage.as_str()
}
}
#[cfg_attr(
doc,
doc = "MemoryCatalogDescription\n\nRuntime catalog entry for one stable-memory allocation."
)]
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq)]
pub struct MemoryCatalogDescription {
tag: String,
memory_id: u8,
store_path: String,
}
impl MemoryCatalogDescription {
#[must_use]
pub const fn new(tag: String, memory_id: u8, store_path: String) -> Self {
Self {
tag,
memory_id,
store_path,
}
}
#[must_use]
pub const fn tag(&self) -> &str {
self.tag.as_str()
}
#[must_use]
pub const fn memory_id(&self) -> u8 {
self.memory_id
}
#[must_use]
pub const fn store_path(&self) -> &str {
self.store_path.as_str()
}
}