Skip to main content

Registries

Struct Registries 

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

The registries of one app. Cloning gives another handle to the same registries; use Registries::new for a separate app.

Implementations§

Source§

impl Registries

Source

pub fn register_editor(&self, script_url: impl Into<String>)

Sets the URL of the script that turns wysiwyg textareas into an editor. The panel loads it with <script src="..." defer> on each form with a wysiwyg field, from the next request on. Registering again replaces the URL. With no script registered, a wysiwyg field is a plain textarea.

Source

pub fn editor_script(&self) -> Option<String>

The URL of the registered editor script, if the app registered one.

Source§

impl Registries

Source

pub fn register_media_library(&self, library: impl MediaLibrary)

Sets the media library that media fields use, from the next request on. Registering again replaces it.

Source

pub fn media_library(&self) -> Option<Arc<dyn MediaLibrary>>

The registered media library, if the app registered one.

Source§

impl Registries

Source

pub fn register_policy(&self, slug: impl Into<String>, policy: impl Policy)

Registers policy for the resource at slug, static or runtime, as Laravel’s Gate::policy maps a model to its policy. It takes effect from the next request on, and replaces the policy the slug had. The slug need not be registered yet: a policy is kept when its runtime resource is removed and registered again.

Source

pub fn unregister_policy(&self, slug: &str) -> bool

Removes the policy of the resource at slug, so its abilities alone decide again. Returns whether it had one.

Source

pub fn policy(&self, slug: &str) -> Option<Arc<dyn Policy>>

The policy of the resource at slug, if one is registered.

Source§

impl Registries

Source

pub fn new() -> Self

An empty set of registries, for a new app.

Source

pub fn default_app() -> Self

The default app’s registries: the process-wide set that the free functions of ignite_core (such as register_runtime) act on, and that a panel built with Ignite::new() serves when it takes no handle. Every call returns a handle to the same registries.

Source

pub fn same_app(&self, other: &Registries) -> bool

Whether other is a handle to the same registries as self.

Source§

impl Registries

Source

pub fn register_runtime( &self, resource: RuntimeResource, ) -> Result<(), RuntimeError>

Adds a runtime resource to this app. It shows in the navigation and the dashboard, and its list, forms and delete action answer at /<mount>/<slug>, from the next request on. Create its permissions (<slug>.viewAny and the others) in the same request with ignite_panel::register_runtime_permissions; otherwise the panel creates them on the next signed-in request.

Refuses a slug that is not valid, a slug that a static resource, another runtime resource of this app or one of the panel’s own pages (such as login) uses, and two fields with one name. Another app’s resources are not consulted: each app has its own registry.

Source§

impl Registries

Source

pub fn unregister_runtime(&self, slug: &str) -> Result<(), RuntimeError>

Removes the runtime resource at slug. From the next request on, it is gone from the navigation and its routes answer 404. Its permission rows stay, so the grants come back if the resource is registered again.

Source

pub fn runtime_resource(&self, slug: &str) -> Option<Arc<RegisteredResource>>

The runtime resource at slug, if one is registered.

Source

pub fn runtime_resources(&self) -> Vec<Arc<RegisteredResource>>

Every runtime resource, in registration order.

Source

pub fn reserve_slugs(&self, slugs: &[&str]) -> Result<(), RuntimeError>

Reserves slugs, so no runtime resource can take them. The panel reserves the slugs of its static resources and of its own pages when it is built. Reserving a slug twice is fine. Refuses, and reserves none, when a runtime resource already has one of them.

Trait Implementations§

Source§

impl Clone for Registries

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 Registries

Source§

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

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

impl Default for Registries

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Registries

§

impl Freeze for Registries
where *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze,

§

impl Move for Registries

§

impl RefUnwindSafe for Registries

§

impl Send for Registries
where Arc<Inner>: Send,

§

impl Sync for Registries
where Arc<Inner>: Sync,

§

impl Unpin for Registries
where Arc<Inner>: Unpin,

§

impl UnsafeUnpin for Registries
where *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin,

§

impl UnwindSafe for Registries
where Arc<Inner>: UnwindSafe,

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