dovecote_sqlx_postgres/
lib.rs1#![warn(missing_docs)]
10#![forbid(unsafe_code)]
11
12mod delivery_state;
13mod enqueue;
14mod error;
15mod finalize;
16mod hydrate;
17mod import;
18mod lifecycle;
19mod lifecycle_mutation;
20mod migration;
21mod page;
22mod rls;
23mod schema;
24mod scope;
25
26pub use error::{
27 ClaimError, EnqueueError, FinalizeError, ImportError, MutationError, PageError, SchemaError,
28 TransientKind,
29};
30#[allow(
31 deprecated,
32 reason = "Preserve the published 0.2.0 migration symbol and its bytes."
33)]
34pub use migration::V1_TENANT_ACTIVATE_SQL;
35pub use migration::{
36 CrateVersion, LEGACY_MIGRATION, MIGRATIONS, Migration, MigrationCompatibility,
37 MigrationCompatibilityError, SCHEMA_VERSION, V1_TENANT_ACTIVATE_V2_SQL, V1_TENANT_PREPARE_SQL,
38};
39pub use page::SnapshotPager;
40pub use rls::{RLS_PROFILE_SQL, bind_tenant};
41pub use schema::check_schema;
42
43use sqlx::PgPool;
44
45pub use scope::{AdminDovecote, TenantDovecote};
46
47#[derive(Clone)]
49pub struct PostgresDovecote {
50 pool: PgPool,
51}
52
53impl PostgresDovecote {
54 #[must_use]
56 pub const fn new(pool: PgPool) -> Self {
57 Self { pool }
58 }
59
60 #[must_use]
62 pub const fn pool(&self) -> &PgPool {
63 &self.pool
64 }
65
66 #[must_use]
68 pub fn for_tenant(&self, tenant: dovecote::TenantId) -> TenantDovecote {
69 TenantDovecote::new(self.pool.clone(), tenant)
70 }
71
72 #[must_use]
77 pub fn admin(&self) -> AdminDovecote {
78 AdminDovecote::new(self.pool.clone())
79 }
80
81 pub async fn check_schema(&self) -> Result<(), SchemaError> {
88 check_schema(&self.pool).await
89 }
90}