Skip to main content

cloudillo_core/
lib.rs

1//! Core infrastructure for the Cloudillo platform.
2//!
3//! This crate contains shared infrastructure modules that are used by the server
4//! crate and potentially by future feature crates. Extracting these into a separate
5//! crate enables better build parallelism and clearer module boundaries.
6
7#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
8#![forbid(unsafe_code)]
9
10pub mod abac;
11pub mod acme;
12pub mod app;
13pub mod bootstrap_types;
14pub mod core_settings;
15pub mod create_perm;
16pub mod dns;
17pub mod extensions;
18pub mod extract;
19pub mod file_access;
20pub mod middleware;
21pub mod prelude;
22pub mod rate_limit;
23pub mod request;
24pub mod roles;
25pub mod scheduler;
26pub mod settings;
27pub mod ws_broadcast;
28pub mod ws_bus;
29
30use std::future::Future;
31use std::net::IpAddr;
32use std::pin::Pin;
33
34// Re-export commonly used types
35pub use app::{App, AppBuilderOpts, AppState, ServerMode};
36pub use extract::{Auth, IdTag, OptionalAuth};
37pub use middleware::{PermissionCheckFactory, PermissionCheckInput, PermissionCheckOutput};
38pub use ws_broadcast::BroadcastManager;
39
40/// Type-erased function for verifying action tokens.
41/// Registered as an extension by the server's action module.
42/// Used by auth module for the token exchange flow.
43pub type ActionVerifyFn = Box<
44	dyn for<'a> Fn(
45			&'a app::App,
46			cloudillo_types::types::TnId,
47			&'a str,
48			Option<&'a IpAddr>,
49		) -> Pin<
50			Box<
51				dyn Future<
52						Output = cloudillo_types::error::ClResult<
53							cloudillo_types::auth_adapter::ActionToken,
54						>,
55					> + Send
56					+ 'a,
57			>,
58		> + Send
59		+ Sync,
60>;
61
62/// Type-erased function for creating a complete tenant (bootstrap).
63/// Registered as an extension by the server's bootstrap module.
64/// Used by profile crate for registration and community creation.
65pub type CreateCompleteTenantFn = Box<
66	dyn for<'a> Fn(
67			&'a app::App,
68			bootstrap_types::CreateCompleteTenantOptions<'a>,
69		) -> Pin<
70			Box<
71				dyn Future<Output = cloudillo_types::error::ClResult<cloudillo_types::types::TnId>>
72					+ Send
73					+ 'a,
74			>,
75		> + Send
76		+ Sync,
77>;
78
79/// Type-erased function for creating an action.
80/// Registered as an extension by the server's action module.
81/// Used by profile crate for community CONN creation.
82pub type CreateActionFn = Box<
83	dyn for<'a> Fn(
84			&'a app::App,
85			cloudillo_types::types::TnId,
86			&'a str,
87			cloudillo_types::action_types::CreateAction,
88		) -> Pin<
89			Box<dyn Future<Output = cloudillo_types::error::ClResult<Box<str>>> + Send + 'a>,
90		> + Send
91		+ Sync,
92>;
93
94/// Type-erased function for ensuring a remote profile exists locally.
95/// Registered as an extension by the server's app module.
96/// Used by action hooks for profile sync.
97pub type EnsureProfileFn = Box<
98	dyn for<'a> Fn(
99			&'a app::App,
100			cloudillo_types::types::TnId,
101			&'a str,
102		) -> Pin<
103			Box<dyn Future<Output = cloudillo_types::error::ClResult<bool>> + Send + 'a>,
104		> + Send
105		+ Sync,
106>;
107
108pub fn register_settings(
109	registry: &mut settings::SettingsRegistry,
110) -> cloudillo_types::error::ClResult<()> {
111	core_settings::register_settings(registry)
112}
113
114// vim: ts=4