uqa_engine/capabilities/
shell_types.rs1use super::super::Engine;
10use uqa_execution::catalog::shell_type::{
11 ShellRegistry, ShellRegistryPublication, ShellRegistryRead,
12};
13
14impl Engine {
15 pub(crate) fn shell_completion_context(
16 &self,
17 ) -> uqa_execution::schema::shell_types::ShellCompletionContext<'_> {
18 uqa_execution::schema::shell_types::ShellCompletionContext {
19 publication: self,
20 locks: self,
21 }
22 }
23 pub(crate) fn shell_type_context(
24 &self,
25 ) -> uqa_execution::schema::shell_types::ShellTypeContext<'_> {
26 uqa_execution::schema::shell_types::ShellTypeContext {
27 registries: uqa_execution::schema::types::arrays::UserTypeRegistries {
28 enums: self,
29 domains: self,
30 composites: self,
31 },
32 creation: self.relation_creation_context(),
33 identities: self.catalog_identity_reservation_context(),
34 writer: self,
35 allocate_identity: || {
36 crate::new_nonzero_catalog_identity("shell", "object identity")
37 .map_err(|error| uqa_sql::SQLError::Internal(error.to_string()))
38 },
39 publication: self,
40 changes: self,
41 }
42 }
43
44 pub(crate) fn restore_shells_from_catalog(
45 &self,
46 catalog: &dyn uqa_storage::CatalogFacade,
47 ) -> uqa_storage::StorageBackendResult<()> {
48 *self.durable.shells.write() =
49 uqa_execution::catalog::shell_type::restore(catalog, &self.durable.roles.read())?;
50 Ok(())
51 }
52}
53
54impl ShellRegistryPublication for Engine {
55 fn shell_registry(&self) -> ShellRegistryRead<'_> {
56 Box::new(self.durable.shells.read())
57 }
58 fn shell_catalog(&self) -> Option<&dyn uqa_storage::CatalogFacade> {
59 self.storage.catalog.as_deref()
60 }
61 fn shell_role_definitions(
62 &self,
63 ) -> std::collections::BTreeMap<String, uqa_sql::catalog::roles::RoleDefinition> {
64 self.durable.roles.read().clone()
65 }
66 fn publish_shell_definitions(&self, registry: ShellRegistry) {
67 *self.durable.shells.write() = registry;
68 }
69}