Skip to main content

Admin

Struct Admin 

Source
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

Source

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.

Source

pub fn site_branding(self, branding: SiteBranding) -> Self

Override the default RustIO branding.

Source

pub fn branding(&self) -> &SiteBranding

Read-only access to the active branding.

Source

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.

Source

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.

Source

pub fn accent(&self) -> Option<&str>

Read-only access to the configured accent colour, if any. None means “no override — admin.css owns it”.

Source

pub fn active_theme(&self) -> &AdminTheme

Read-only access to the active theme override patch.

Source

pub fn model<M>(self) -> Self
where M: ModelAdmin + Model,

Source

pub fn entries(&self) -> &[AdminEntry]

Source

pub fn user_profile_extension<F, Fut>(self, ext: F) -> Self
where 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.

Source

pub fn find(&self, admin_name: &str) -> Option<&AdminEntry>

Source

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§

Source§

impl Default for Admin

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more