pub struct Admin { /* private fields */ }Expand description
Builder for the admin. Register models with .model::<M>(), then
hand it to the router via register_admin_routes.
Implementations§
Source§impl Admin
impl Admin
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new Admin with the framework’s core entries
pre-seeded. The only core entry is User; project models are
added on top via Self::model.
Sourcepub fn site_branding(self, branding: SiteBranding) -> Self
pub fn site_branding(self, branding: SiteBranding) -> Self
Override the default RustIO branding.
Sourcepub fn branding(&self) -> &SiteBranding
pub fn branding(&self) -> &SiteBranding
Read-only access to the active branding.
Sourcepub fn accent_color(self, color: impl Into<String>) -> Self
pub fn accent_color(self, color: impl Into<String>) -> Self
Set the admin chrome’s accent colour. Hex form, with or without
the leading # ("#1e6ba8" and "1e6ba8" both work). Replaces
any prior accent override; other AdminTheme fields are
left untouched.
Sourcepub fn theme(self, theme: AdminTheme) -> Self
pub fn theme(self, theme: AdminTheme) -> Self
Replace the entire admin chrome palette patch in one call. See
AdminTheme for the field-by-field contract.
Sourcepub fn accent(&self) -> Option<&str>
pub fn accent(&self) -> Option<&str>
Read-only access to the configured accent colour, if any. None
means “no override — admin.css owns it”.
Sourcepub fn active_theme(&self) -> &AdminTheme
pub fn active_theme(&self) -> &AdminTheme
Read-only access to the active theme override patch.
pub fn model<M>(self) -> Selfwhere
M: ModelAdmin + Model,
pub fn entries(&self) -> &[AdminEntry]
Sourcepub fn user_profile_extension<F, Fut>(self, ext: F) -> Selfwhere
F: Fn(Db, UserProfile) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Vec<UserProfileSection>>> + Send + 'static,
pub fn user_profile_extension<F, Fut>(self, ext: F) -> Selfwhere
F: Fn(Db, UserProfile) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<Vec<UserProfileSection>>> + Send + 'static,
Register a project-specific extension that contributes extra
sections to the built-in user profile page. The closure is
invoked on every render of GET /admin/users/:id (Overview tab);
it receives the Db handle and the loaded
crate::auth::UserProfile (no password_hash) and returns a
Vec<UserProfileSection>. Sections render in the order returned,
immediately after the core profile show-grid.
Zero-config baseline: don’t call this method, and the extension
area stays empty. Projects that need richer layout than key-value
rows override the {% block project_user_fields %} template
block in templates/admin/user_view.html instead.
pub fn find(&self, admin_name: &str) -> Option<&AdminEntry>
Sourcepub async fn seed_permissions(&self, db: &Db) -> Result<()>
pub async fn seed_permissions(&self, db: &Db) -> Result<()>
Register the canonical (add/change/delete/view) permissions for
every model. Call during startup after init_tables.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Admin
impl !RefUnwindSafe for Admin
impl Send for Admin
impl Sync for Admin
impl Unpin for Admin
impl UnsafeUnpin for Admin
impl !UnwindSafe for Admin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more