Skip to main content

RegisteredResource

Struct RegisteredResource 

Source
pub struct RegisteredResource { /* private fields */ }
Expand description

A runtime resource as the registry holds it: the definition, ready for the panel.

Implementations§

Source§

impl RegisteredResource

Source

pub fn resource(&self) -> &RuntimeResource

The definition that was registered.

Source

pub fn slug(&self) -> &str

The slug, as the panel’s routes match it.

Source

pub fn title(&self) -> &str

The heading and navigation label.

Source

pub fn singular(&self) -> &str

The name of one record.

Source

pub fn navigation_label(&self) -> &str

The label of the navigation entry: the navigation label, or the title.

Source

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

The navigation group the resource is listed under, if any.

Source

pub fn navigation_sort(&self) -> Option<i32>

The resource’s place in the navigation, if set.

Source

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

The name of the navigation entry’s icon, if set.

Source

pub fn fields(&self) -> &[FieldDef]

The form fields, in display order.

Source

pub fn columns(&self) -> &[ColumnDef]

The list columns, in display order.

Source

pub fn validate(&self, form: &FormInput) -> Result<Row, FieldErrors>

Turns the submitted form into a Row for a create, or returns one message per field. It runs the same checks as a static resource, with the same messages: required fields (Field::check_required), whole numbers, decimals, dates, date-times and select choices. The row holds one key per field:

  • text, textarea, select, lookup: a string. A required value is trimmed.
  • email, URL, radio, color, image, file, link, wysiwyg, post object, relationship, taxonomy, user, repeater, group, flexible content, gallery, clone: the text Field::check_value returns. The structured kinds hold JSON text.
  • number: an integer. Decimal: a number.
  • checkbox: true or false; a checkbox is never blank.
  • date: "YYYY-MM-DD". Date-time: "YYYY-MM-DD HH:MM:SS".
  • password: the hash of the password (hash_password).
  • a blank field that is not required: null.

Each error in FieldErrors is keyed by the field’s name, an owned String.

A lookup, post object, relationship, taxonomy or user value is checked against RuntimeData::options by the panel, which can read the database, and so is a media id against the registered MediaLibrary.

Source

pub fn validate_update(&self, form: &FormInput) -> Result<Row, FieldErrors>

Turns the submitted form into a Row for an update. It is validate, except that:

  • a blank password is not an error: the row leaves its key out, so the stored password is kept;
  • an optional field the form did not send at all (FormInput::has is false) is left out of the row, so its stored value is kept;
  • an optional field sent blank is null, so clearing it on the edit form clears the stored value, as #[derive(IgniteResource)] does since 0.3.0;
  • a checkbox the form did not send is false, because an unticked HTML checkbox sends nothing.
Source

pub fn conditions(&self) -> &FieldConditions

The conditions that show or hide the form’s fields.

Source

pub fn validate_shown( &self, form: &FormInput, hidden: &BTreeSet<String>, ) -> Result<Row, FieldErrors>

validate for a form whose fields hidden are hidden (see FieldConditions::hidden_fields): they are not checked, a required one included, and the row has no key for them, so the source writes nothing for them. The panel calls it.

Source

pub fn validate_update_shown( &self, form: &FormInput, hidden: &BTreeSet<String>, ) -> Result<Row, FieldErrors>

validate_update for a form whose fields hidden are hidden: the row has no key for them, so their stored values are kept, whatever the form sent.

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<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 = !

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<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