pub struct ResourceEntry {Show 17 fields
pub meta: AdminResource,
pub form_builder: FormBuilder,
pub edit_form_builder: Option<FormBuilder>,
pub list_fn: Option<ListFn>,
pub get_fn: Option<GetFn>,
pub delete_fn: Option<DeleteFn>,
pub update_fn: Option<UpdateFn>,
pub partial_update_fn: Option<UpdateFn>,
pub create_fn: Option<CreateFn>,
pub count_fn: Option<CountFn>,
pub filter_fn: Option<FilterFn>,
pub group_actions: Vec<GroupAction>,
pub m2m_loader: Option<M2mLoaderFn>,
pub unique_fields: &'static [&'static str],
pub own_field: Option<&'static str>,
pub enum_label_fn: Option<EnumLabelFn>,
pub table: Option<&'static str>,
}Expand description
Admin registry entry: metadata + CRUD closures.
Fields§
§meta: AdminResource§form_builder: FormBuilder§edit_form_builder: Option<FormBuilder>§list_fn: Option<ListFn>§get_fn: Option<GetFn>§delete_fn: Option<DeleteFn>§update_fn: Option<UpdateFn>§partial_update_fn: Option<UpdateFn>§create_fn: Option<CreateFn>§count_fn: Option<CountFn>§filter_fn: Option<FilterFn>§group_actions: Vec<GroupAction>§m2m_loader: Option<M2mLoaderFn>§unique_fields: &'static [&'static str]§own_field: Option<&'static str>Field name used to verify record ownership when can_update_own/can_delete_own is set.
If None, “own” permissions are blocked (safe default until the field is declared).
enum_label_fn: Option<EnumLabelFn>Model-provided resolver turning enum db values into display labels (display views).
table: Option<&'static str>The table the resource’s entity reads, from the entity itself
(Entity::table_name()). None for a resource that didn’t declare it.
Implementations§
Source§impl ResourceEntry
impl ResourceEntry
Sourcepub fn new(meta: AdminResource, form_builder: FormBuilder) -> Self
pub fn new(meta: AdminResource, form_builder: FormBuilder) -> Self
Creates a resource entry with only metadata and a form builder set;
every CRUD closure defaults to None until wired up via the with_* builders.
Sourcepub fn with_table(self, table: &'static str) -> Self
pub fn with_table(self, table: &'static str) -> Self
Declares the table the resource’s entity reads. Generated admin code
passes Entity::table_name(), so it can’t drift from the model.
Sourcepub fn is_account_table(&self) -> bool
pub fn is_account_table(&self) -> bool
Whether the resource is the accounts table (eihwaz_users) — the
built-in users, or a model extending it with extend!{}. Only those
may send a password reset.
Sourcepub fn with_enum_label_fn(self, f: EnumLabelFn) -> Self
pub fn with_enum_label_fn(self, f: EnumLabelFn) -> Self
Registers the enum-label resolver used to turn raw enum db values into display labels in list/detail/delete views. Used by generated admin resource code; not typically called directly.
Sourcepub fn with_m2m_loader(self, f: M2mLoaderFn) -> Self
pub fn with_m2m_loader(self, f: M2mLoaderFn) -> Self
Registers the closure that loads many-to-many field options for the create/edit form.
Sourcepub fn with_edit_form_builder(self, f: FormBuilder) -> Self
pub fn with_edit_form_builder(self, f: FormBuilder) -> Self
Registers a dedicated form builder for the edit view, used instead of
form_builder when the edit form differs from the create form.
Sourcepub fn with_list_fn(self, f: ListFn) -> Self
pub fn with_list_fn(self, f: ListFn) -> Self
Registers the closure that returns a page of resource entries for the list view.
Sourcepub fn with_get_fn(self, f: GetFn) -> Self
pub fn with_get_fn(self, f: GetFn) -> Self
Registers the closure that fetches a single entry by its ID.
Sourcepub fn with_delete_fn(self, f: DeleteFn) -> Self
pub fn with_delete_fn(self, f: DeleteFn) -> Self
Registers the closure that deletes an entry by its ID.
Sourcepub fn with_update_fn(self, f: UpdateFn) -> Self
pub fn with_update_fn(self, f: UpdateFn) -> Self
Registers the closure that fully updates an entry from validated form data.
Sourcepub fn with_partial_update_fn(self, f: UpdateFn) -> Self
pub fn with_partial_update_fn(self, f: UpdateFn) -> Self
Registers the closure used for partial updates (e.g. group/bulk field updates).
Sourcepub fn with_create_fn(self, f: CreateFn) -> Self
pub fn with_create_fn(self, f: CreateFn) -> Self
Registers the closure that creates a new entry from validated form data.
Sourcepub fn with_count_fn(self, f: CountFn) -> Self
pub fn with_count_fn(self, f: CountFn) -> Self
Registers the closure that returns the total row count, used for pagination.
Sourcepub fn with_filter_fn(self, f: FilterFn) -> Self
pub fn with_filter_fn(self, f: FilterFn) -> Self
Registers the closure that returns the distinct values available for
each list_filter sidebar column.
Sourcepub fn with_unique_fields(self, fields: &'static [&'static str]) -> Self
pub fn with_unique_fields(self, fields: &'static [&'static str]) -> Self
Declares which field names carry a unique DB constraint on the underlying model. Used to exclude them from bulk edit, since applying the same value to multiple rows would violate the constraint.
Sourcepub fn with_own_field(self, field: &'static str) -> Self
pub fn with_own_field(self, field: &'static str) -> Self
Declares the field used to verify record ownership when
can_update_own/can_delete_own permissions are set.
Sourcepub fn with_group_actions(self, actions: Vec<GroupAction>) -> Self
pub fn with_group_actions(self, actions: Vec<GroupAction>) -> Self
Registers the bulk (group) actions available in the list view, merging choices together for actions declared multiple times on the same field.
Auto Trait Implementations§
impl !RefUnwindSafe for ResourceEntry
impl !UnwindSafe for ResourceEntry
impl Freeze for ResourceEntry
impl Send for ResourceEntry
impl Sync for ResourceEntry
impl Unpin for ResourceEntry
impl UnsafeUnpin for ResourceEntry
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<F, T> ConvertInto<T> for Fwhere
T: ConvertFrom<F>,
impl<F, T> ConvertInto<T> for Fwhere
T: ConvertFrom<F>,
Source§fn convert_into(self) -> T
fn convert_into(self) -> T
Self to a value of type T.Source§impl<F, T> ConvertTryFrom<F> for Twhere
F: ConvertInto<T>,
impl<F, T> ConvertTryFrom<F> for Twhere
F: ConvertInto<T>,
Source§impl<F, T> ConvertTryInto<T> for Fwhere
T: ConvertTryFrom<F>,
impl<F, T> ConvertTryInto<T> for Fwhere
T: ConvertTryFrom<F>,
Source§type Error = <T as ConvertTryFrom<F>>::Error
type Error = <T as ConvertTryFrom<F>>::Error
Source§fn convert_try_into(self) -> Result<T, <T as ConvertTryFrom<F>>::Error>
fn convert_try_into(self) -> Result<T, <T as ConvertTryFrom<F>>::Error>
Self to a value of type T.impl<T> ErasedDestructor for Twhere
T: 'static,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> 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