#[non_exhaustive]pub struct Resource {
pub base_path: String,
pub nav_label: Text,
pub list: ListConfig,
pub form: Option<FormConfig>,
pub permission: Option<String>,
}Expand description
An admin resource: a list screen, optionally with a create/edit form, mounted
under base_path and shown in the menu as nav_label.
Built with Resource::new plus its builder methods. Non-exhaustive because
this is the descriptor a plugin author writes and the one most likely to grow:
a struct literal outside this crate would freeze its field set at 1.0, so the
framework could never learn anything new about a resource.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.base_path: StringThe path the resource mounts at, relative to the admin root and starting
with a slash (e.g. /products). The framework prepends the configured
admin mount, so a resource never hardcodes it and survives a moved panel.
The list’s edit_base and the form’s base_path are resolved the same
way.
The menu label, localized at render. Serde stays a plain string.
list: ListConfig§form: Option<FormConfig>§permission: Option<String>The permission an operator must hold to reach any of the resource’s
routes. A dotted string gates every route the resource mounts, and an
operator who lacks it receives 403 Forbidden; superusers pass regardless.
None leaves the resource open to any signed-in operator and is allowed
only for a read-only resource: a resource with a create/edit form must
declare a permission, or boot aborts (see [mount_resource]).
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn new(
base_path: impl Into<String>,
nav_label: impl Into<Text>,
list: ListConfig,
) -> Self
pub fn new( base_path: impl Into<String>, nav_label: impl Into<Text>, list: ListConfig, ) -> Self
A read-only resource: a list at base_path, in the menu as nav_label.
A create/edit form is added with Resource::form, which also requires
Resource::permission: an unguarded write resource aborts boot.
Sourcepub fn form(self, form: FormConfig) -> Self
pub fn form(self, form: FormConfig) -> Self
Adds the create/edit form. A resource with one must also declare a permission, or boot aborts.
Sourcepub fn permission(self, permission: impl Into<String>) -> Self
pub fn permission(self, permission: impl Into<String>) -> Self
The permission gating every route this resource mounts.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Resource
impl RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl UnsafeUnpin for Resource
impl UnwindSafe for Resource
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
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> 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