Expand description
§adminx
A framework-neutral admin-panel framework. This crate is a facade: it
re-exports the neutral adminx_core plus whichever framework and storage
adapters you enable via Cargo features, so you depend on a single crate.
# Axum + PostgreSQL/MySQL/SQLite:
adminx = { version = "2", features = ["axum", "seaorm"] }
# Actix + MongoDB:
adminx = { version = "2", features = ["actix", "mongo"] }§Usage
ⓘ
use adminx::prelude::*; // Resource, ReqCtx, ApiResponse, auth, ...
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
adminx::seaorm::init("postgres://localhost/mydb").await?; // storage adapter
register_resource(Box::new(UserResource));
let app = axum::Router::new().nest("/adminx", adminx::axum::router());
let l = tokio::net::TcpListener::bind("0.0.0.0:8080").await?;
axum::serve(l, app).await?;
Ok(())
}The framework/storage integrations live under [self::actix] / self::axum
and self::seaorm / self::mongo, each present only when its feature is
enabled. Everything else (the Resource trait, prelude, auth, UI) comes
straight from the core.
Re-exports§
pub use adminx_core as core;pub use adminx_axum as axum;axumpub use adminx_seaorm as seaorm;seaormpub use adminx_mongo as mongo;mongopub use adminx_rbac as rbac;rbacpub use adminx_audit as audit;auditpub use adminx_attachments as attachments;attachmentspub use adminx_search as search;search
Modules§
- actions
- attach
- auth
- authz
- crud
- csrf
- error
- export
- filters
- menu
- mfa
- prelude
- Common imports for defining resources and wiring an app.
- ratelimit
- registry
- request
- resource
- response
- storage
- ui
Structs§
- ApiResponse
- Attachment
- One stored attachment, as the detail page and the serve route need it.
- Audit
Entry - One recorded change to one record.
- Auth
Config - Claims
- Authenticated principal, decoded from the auth cookie by
auth::build_ctx. - Create
Outcome - Result of an insert.
last_insert_idis backend-dependent (MySQL yields an autoincrement id; Postgres a RETURNING id when available). - Custom
Action - Describes a custom action exposed by a resource.
- File
Field - A file field a resource exposes on its detail page. Declared from
Resource::file_fields. - Filter
Field - A filter a resource exposes on its list page. Declare these from
Resource::filterable_fields; the list UI and query builder do the rest. - Filter
Option - One option in a
Selectfilter. - List
Page - One page of rows plus the total count for pagination.
- Menu
Item - Query
Options - Pagination + ordering + filters distilled from a request query string.
- ReqCtx
- Uploaded
File - A file arriving on an upload request. The adapter builds this from the
multipart body;
bytesis the whole file held in memory (fine for the admin use-case — logos, avatars, small docs — a streaming path can come later).
Enums§
- Action
- The operation being authorized. Borrows so
Customcarries a handler’s&strname without allocating; it’sCopy, and the lifetime elides toAction<'_>at every call site. - ApiBody
- Audit
Event - What happened to a record.
- Core
Error - Framework-neutral error. Adapters map this onto their own response type.
- Filter
Kind - The kind of input rendered for a filter, and how its value is matched.
- Menu
Action - Storage
Error
Constants§
Traits§
- Attachments
- A pluggable attachment backend: stores the bytes somewhere and records the metadata so it can be listed and served back.
- Auditor
- A pluggable audit sink. Unlike
Authorizerthis is async and does I/O — it runs once per mutation, not several times per request. - Authorizer
- A pluggable authorization policy.
canis synchronous and called several times per request, so an implementation must not perform I/O here — a DB-backed one reads a pre-loaded in-memory cache. - Indexer
- A pluggable search index. Keyed by
index(a resource’sbase_path()), so one backend serves every searchable resource. Async — it does I/O, once per mutation, not per request. - Resource
- Storage
Functions§
- all_
resources - attachments
- The registered backend, if any.
- auditor
- The registered auditor, if any.
- authorizer
- The registered authorizer, if any.
Nonemeans the built-in role-list check is used. - get_
registered_ menus - Collect and group menus from every registered resource.
- indexer
- The registered indexer, if any.
- register_
resource - Register a resource globally.
- seed
- Seed the database by running a batch of raw statements against the active backend, in order, stopping at the first error. Write SQL when using a SeaORM backend, or JSON command documents when using Mongo — the same call works for both, you just author for whichever backend you registered.
- set_
attachments - Register the global attachment backend. Set-once, matching the other seams.
- set_
auditor - Register the global audit sink. Set-once, matching
set_storageandset_authorizer. - set_
authorizer - Register the global authorization policy. Set-once: a later call is ignored
with a warning, matching
set_storage. - set_
indexer - Register the global search backend. Set-once, matching the other seams.
- set_
storage - Register the global storage backend. Call once during startup.
- set_
tailwind_ src - Point the admin UI at a different Tailwind/CSS source (e.g. a self-hosted
stylesheet you serve yourself) instead of the CDN default. Set once, before
serving; the
ADMINX_TAILWIND_SRCenv var is honoured as a fallback. - storage
- Access the global storage backend. Panics if never initialized.
Type Aliases§
- Action
Future - Boxed future returned by an action handler.
- Action
Handler - An action handler receives the (cloned) request context, the target record
id, and the JSON request body (
{}when none was sent).