Skip to content
kylekingcdnPublic

About

Framework of common glue code for Rust binaries

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

elme-rs

A set of crates providing glue code for Rust applications.

This and associated crates are currently a work in progress.

Until stabilized, usage in production code is strongly discouraged.

crates.io | Docs | GitHub


Certified Non AI Slop

Each crate in the elme framework was crafted by hand keyboard with care.

I take personal credit for the (hopefully) rare case where you believe some code to be of a sloppy nature.

For these cases, please open an issue or submit a PR - it's very much appreciated!

Jump to module

Installation

By default, elme ships with 0 dependencies and all modules disabled.

Modules can be enabled via feature flags:

cargo add elme --features [module_name]

Cargo.toml example

[dependencies]
elme = { version = "0.0.1", features = ["config","shutdown"] }

Note


Opting into modules using feature flags via the elme crate provides identical performance to manually depending on each module's respective crate.

Therefore, depending on the elme crate as opposed to depending on each respective module crate is the recommended versioning strategy.

Breakdown of modules/crates

elme

Module re-exports - each module is gated by a feature flag.

This is the the recommended method of integrating elme modules.

crates.io | Docs | GitHub

Feature flags

See the following list for feature flags relevant to each module.

elme-config

elme-config is a very small convenience module.

Supported features:

  • A ConfigureApp trait for an app's root config struct
    • Contains default impl of a load() method, reading vals from .env files + env vars
    • Replaces the need for any and all config logic in standard cases
  • Pulls in config and dotenvy deps, removing one-off dependency burden

crates.io | Docs | GitHub

Relevant elme feature flags

Flag Description
config Enables this module

elme-db

Provides types supporting:

  • Managed/unmanaged database wrapper structs
    • Managed db's are a superset of unmanaged w/ migration support
    • Can optionally be used to scope query availability in associated Repo impl's, e.g.
      1. Restrict repos backed by an UnmanagedDatabase to read-only queries (select, count, etc)
      2. Provide additional access to mutable queries when the Repo is backed with a ManagedDatabase
  • Managed/unmanaged db config with types automatically mapped to PgPoolOptions

And provides utility traits supporting:

  • Repo trait provides repository pattern on a per-table basis, with associated Row types and a clean interface
  • Common query operations (insert one, insert many, etc) [db-op-traits feature only]
    • Boilerplate logic auto impl'd, simply provide the statement and query.bind() call
    • Allows for inline chaining of queries - with optional, automatic tx commit/rollback handling
This module currently only supports sqlx used with PostgreSQL databases.

Support may be extended in the future.

crates.io | Docs | GitHub

Relevant elme feature flags

Flag Description
db Enables this module
db-op-traits Enables the op-traits feature of elme-db
This feature includes traits used for repo operations (insert, batch insert, delete, etc)
Feature docs

elme-error

Provides types for propagating errors, spantraces, and backtraces.

Similar functionality to eyre, color-eyre, anyhow, etc - with the following additions:

  • Configuration of backtrace/spantrace format/visibility on a per-destination basis.
  • Configuration of ANSI/color output on a per-destination basis.

For example, this could allow for the following (simultaneously):

  • Output error messages with color backtraces in full to terminal
  • Output error messages with non-color backtraces in full to a file
  • Output error message strings to OTEL - with backtraces embedded in structured attra/metadata as opposed to the body
Docs and module impls will be published soon

crates.io | Docs | GitHub

Relevant elme feature flags

Flag Description
error Enables this module

elme-otel

Dead simple, frustration-free OpenTelemetry bootstrapping.

Docs and module impls will be published soon

crates.io | Docs | GitHub

Relevant elme feature flags

Flag Description
otel Enables this module

Contributions

Please forward any letters of gratitude generated by the dependencies section of your Cargo.toml file to our receiving dept.

elme-shutdown

Zero-effort lifecycle management: graceful shutdown, signal handling, task tracking, and more.

Docs and module impls will be published soon

crates.io | Docs | GitHub

Relevant elme feature flags

Flag Description
shutdown Enables this module
shutdown-progress Enables task + timeout progress bars during teardown
shutdown-progress-writer Provides a tracing-subscriber writer for clean tracing + progress output

About

Framework of common glue code for Rust binaries

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages