Expand description
Facilitates preparing an embedded PostgreSQL instance while dropping root
privileges.
The library owns the lifecycle for configuring paths, permissions, and
process identity so the bundled PostgreSQL binaries can initialize safely
under an unprivileged account.
Modules§
- cache
- Shared binary cache for
PostgreSQLdownloads. - extensions
- Prebuilt extension installation for embedded
PostgreSQLtrees. - observability
- Shared tracing configuration and metric recording for observability.
Structs§
- Bootstrap
Error - Captures bootstrap-specific failures.
- Cluster
Guard - Lifecycle guard for a running
PostgreSQLcluster. - Cluster
Handle - Send-safe handle providing read-only access to a running
PostgreSQLcluster. - Connection
Metadata - Provides ergonomic accessors for connection-oriented cluster metadata.
- Database
Name - A strongly-typed database name for use with lifecycle operations.
- PgEnv
Cfg - Captures
PostgreSQLsettings supplied via environment variables. - Privilege
Error - Captures privilege-management failures.
- Temporary
Database - RAII guard that drops a database when it goes out of scope.
- Test
Bootstrap Environment - Holds filesystem and time zone settings used by the bootstrap tests.
- Test
Bootstrap Settings - Structured settings returned from
bootstrap_for_tests. - Test
Cluster - Embedded
PostgreSQLinstance whose lifecycle follows Rust’s drop semantics. - Test
Cluster Connection - Accessor for connection helpers derived from a
TestCluster.
Enums§
- Bootstrap
Error Kind - Categorizes bootstrap failures so callers can branch on structured errors.
- Cleanup
Mode - Controls cleanup behaviour when a cluster is dropped.
- Error
- Top-level error exposed by the crate.
- Execution
Mode - Selects how
PostgreSQLlifecycle commands run when privileged execution is required. - Execution
Privileges - Represents the privileges the process is running with when bootstrapping
PostgreSQL. - Password
Reuse Outcome - Why the bootstrap did or did not adopt a stored password; a bounded label
for the
password_reusetracing event. - PgEmbedded
Error - Top-level error exposed by the crate.
Constants§
- MIN_
MAX_ CONNECTIONS - Smallest
PG_MAX_CONNECTIONSthe helper accepts: one ordinary slot abovePostgreSQL’s default of three reserved superuser connections.
Functions§
- ambient_
dir_ and_ path - Resolves a path to an ambient directory handle paired with the relative path component.
- bootstrap_
for_ tests - Bootstraps
PostgreSQLfor integration tests and surfaces the prepared settings. - default_
paths_ for - Computes default installation and data directories for a given uid.
- default_
paths_ under - Derives the default
installanddatadirectories underroot. - default_
root_ for - Returns the per-user base directory used when
PG_EMBED_ROOTis unset. - detect_
execution_ privileges - Detects whether the process is running with root privileges.
- find_
timezone_ dir - Probes common Unix paths for the time zone database directory.
- make_
data_ dir_ private - Ensures
direxists, is owned byuser, and hasPostgreSQL-compatible 0700 permissions. - make_
dir_ accessible - Ensures
direxists, is owned byuser, and grants world-readable access. - nobody_
uid - Retrieves the UID of the
nobodyaccount, defaulting to 65534 when absent. - reuse_
existing_ password - Aligns
settings.passwordwith the cluster already present indata_dir, unless the caller supplied an explicit password. - run
- Bootstraps an embedded
PostgreSQLinstance, downloads the distribution, and initializes the data directory viainitdb. - stored_
cluster_ password - Reads the password an existing cluster in
data_dirwas initialized with.
Type Aliases§
- Privilege
Result - Result alias for privilege-management fallible operations.
- Result
- Result alias for operations that may return a
PgEmbeddedError.