Skip to main content

SettingsItem

Struct SettingsItem 

Source
#[non_exhaustive]
pub struct SettingsItem { pub code: String, pub label: Text, pub description: Text, pub category: Text, pub hint: Option<Text>, pub confirm_leave: bool, pub order: i32, pub icon: Option<String>, pub permission: Option<String>, pub link: Option<String>, pub fields: Vec<FormField>, pub per_operator: bool, /* private fields */ }
Expand description

A settings model surfaced in the admin: a storage code, a category and order that place it in the index, and the fields to edit.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§code: String

Storage key. Matches the model’s SettingsModel::CODE.

This is a storage key and never a URL. It is dotted, like the module identity it derives from, and a dotted identifier in a path is how these screens spent months at /settings/rainmill.discovery.robots. Where the screen mounts is SettingsItem::route, resolved at boot through the module’s namespace like every other contributed screen.

§label: Text

The item’s label, description, and category heading, localized at render.

§description: Text§category: Text

Group heading in the index.

§hint: Option<Text>

A fuller explanation, shown as a note at the top of this screen and nowhere else. Where SettingsItem::description must stay short enough to read in a sidebar, this has room to say why the screen exists.

§confirm_leave: bool

Ask before leaving this screen with changes unsaved. Default true.

§order: i32

Weight within the category (lower sorts first).

§icon: Option<String>

Icon name shown beside the item in the context sidebar (a Lucide name such as users or shield). None falls back to a generic glyph.

§permission: Option<String>

Permission required to edit, enforced by middleware. None means any authenticated operator.

§link: Option<String>

When set, the item links to this route (e.g. a resource list) instead of its settings form. Used to place list/form screens (like Administrators) in the settings menu rather than the main menu.

§fields: Vec<FormField>§per_operator: bool

Stored once per operator, among their preferences, and edited from the Preferences page rather than Settings. See store::PreferencesModel.

Implementations§

Source§

impl SettingsItem

Source

pub fn new( code: impl Into<String>, label: impl Into<Text>, fields: Vec<FormField>, ) -> Self

A settings screen for code (the model’s SettingsModel::CODE), titled label, editing fields.

Everything else takes a default and is opted into through a builder method, so a field added later costs existing callers nothing.

Source

pub fn per_operator(self) -> Self

Keeps a value per operator, edited from their Preferences page. The permission still applies; the category is not used.

Source

pub fn description(self, text: impl Into<Text>) -> Self

The sentence under the item’s name in the index and sidebar.

Keep it to two lines in the sidebar, which is 72 characters at the panel’s width. A description longer than that stops being a label and starts being a lecture in a column 211 pixels wide; put the explanation in SettingsItem::hint, where the reader has already chosen to look.

Source

pub fn hint(self, text: impl Into<Text>) -> Self

A fuller explanation for the top of this screen. Unlike the description, it has no length limit: the reader has opened the screen.

Source

pub fn confirm_leave(self, ask: bool) -> Self

Whether leaving this screen with changes unsaved asks first. Default true.

Source

pub fn category(self, text: impl Into<Text>) -> Self

The group heading this item sorts under.

Source

pub fn order(self, order: i32) -> Self

Weight within the category; lower sorts first.

Source

pub fn icon(self, icon: impl Into<String>) -> Self

A Lucide icon name shown beside the item.

Source

pub fn permission(self, permission: impl Into<String>) -> Self

The permission required to edit, enforced by middleware.

Point the item at an existing route instead of its own settings form, so a list screen can sit in the settings menu.

Source

pub fn path(&self, admin_path: &str) -> String

Where this item leads, resolved under the admin mount (admin_path): its link target if set, else its own settings screen. Both are authored relative to the admin root, so this prepends the mount.

Trait Implementations§

Source§

impl Clone for SettingsItem

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SettingsItem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for SettingsItem

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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