Skip to main content

ListConfig

Struct ListConfig 

Source
#[non_exhaustive]
pub struct ListConfig {
Show 16 fields pub entity: String, pub title: Text, pub columns: Vec<ListColumn>, pub order_by: String, pub order_dir: SortDir, pub per_page: i64, pub id_field: String, pub edit_base: Option<String>, pub creatable: bool, pub filters: Vec<ListFilter>, pub deletable: bool, pub exportable: bool, pub toolbar: Vec<ToolbarButton>, pub search: SearchConfig, pub per_page_options: Vec<i64>, pub no_records_message: Option<Text>,
}
Expand description

A list view descriptor: which table, which columns, default ordering, page size, and (optionally) where per-row edit links point.

Built with ListConfig::new plus its builder methods. Non-exhaustive, so a struct literal outside this crate cannot freeze the field set at 1.0; that rules out ..Default::default() too, which is why the builders exist.

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.
§entity: String§title: Text

The screen title, localized at render. Serde stays a plain string.

§columns: Vec<ListColumn>§order_by: String§order_dir: SortDir§per_page: i64§id_field: String§edit_base: Option<String>

When set, rows link to {edit_base}/{id}/edit.

§creatable: bool

Whether to offer a “New” link to {edit_base}/new. A resource that only edits existing records (no create screen) sets this false.

§filters: Vec<ListFilter>

Filters offered above the table. Empty hides the bar.

§deletable: bool

Whether rows can be selected and deleted from this list. Off by default: a list that shows a log, or records another screen owns, has no business offering it.

§exportable: bool

Whether this resource offers an export. Off by default: exporting is a capability a resource opts into, not something every list should carry.

§toolbar: Vec<ToolbarButton>

Extra buttons in the toolbar, beside New and the export menu.

§search: SearchConfig§per_page_options: Vec<i64>

Page sizes the operator may choose from in the list setup, remembered with their column choice. Empty offers no choice.

§no_records_message: Option<Text>

Shown when the list has no records at all. None shows “No records yet.”

Implementations§

Source§

impl ListConfig

Source

pub fn new( entity: impl Into<String>, title: impl Into<Text>, columns: Vec<ListColumn>, ) -> Self

A list over entity titled title, showing columns.

Everything else takes the defaults below and is opted into through a builder method, so a field added later costs existing descriptors nothing.

Source

pub fn order(self, column: impl Into<String>, dir: SortDir) -> Self

Orders by column in dir rather than newest id first.

Source

pub fn per_page(self, rows: i64) -> Self

Source

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

The primary-key column, when it is not id.

Source

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

Links rows to {base}/{id}/edit.

Source

pub fn creatable(self) -> Self

Offers a New link to {edit_base}/new. Opt in, matching the read-only default: a list over a log, or over records another screen owns, should not invite an operator to create one.

Source

pub fn exportable(self) -> Self

Offers CSV and JSON exports of the current query. Opt in: a resource whose rows should not leave the panel simply never calls this, and the route is not registered for it.

Source

pub fn filters(self, filters: Vec<ListFilter>) -> Self

Source

pub fn deletable(self) -> Self

Lets rows be selected and deleted. Off by default: a list showing a log, or records another screen owns, has no business offering it.

Source

pub fn toolbar(self, buttons: Vec<ToolbarButton>) -> Self

Source

pub fn search(self, search: SearchConfig) -> Self

Source

pub fn per_page_options(self, sizes: Vec<i64>) -> Self

Source

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

Trait Implementations§

Source§

impl Clone for ListConfig

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 ListConfig

Source§

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

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

impl Default for ListConfig

Source§

fn default() -> Self

A minimal list: no columns, newest-id first, 25 to a page, read-only.

Descriptors use this as the tail of a struct literal (..Default::default()) and set only what they mean. A field added here later is then additive for every descriptor rather than breaking it, which three consecutive additions made the case for.

Source§

impl Serialize for ListConfig

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